@@ -10,7 +10,7 @@ import { Checkbox, Radio, Switch } from './checkbox';
1010afterEach ( cleanup ) ;
1111
1212describe ( 'Checkbox, Radio & Switch components ' , ( ) => {
13- it ( '<Checkbox /> renders correctly and call on change on Press' , async ( ) => {
13+ it ( '<Checkbox /> renders correctly and call on change on Press' , ( ) => {
1414 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
1515 render (
1616 < Checkbox
@@ -22,9 +22,9 @@ describe('Checkbox, Radio & Switch components ', () => {
2222 ) ;
2323 expect ( screen . getByTestId ( 'checkbox' ) ) . toBeOnTheScreen ( ) ;
2424 expect ( screen . queryByTestId ( 'checkbox-label' ) ) . not . toBeOnTheScreen ( ) ;
25- expect (
26- screen . getByTestId ( 'checkbox' ) . props . accessibilityState . checked
27- ) . toBe ( false ) ;
25+ expect ( screen . getByTestId ( 'checkbox' ) ) . toBeEnabled ( ) ;
26+
27+ expect ( screen . getByTestId ( 'checkbox' ) ) . not . toBeChecked ( ) ;
2828 expect ( screen . getByTestId ( 'checkbox' ) . props . accessibilityRole ) . toBe (
2929 'checkbox'
3030 ) ;
@@ -37,7 +37,7 @@ describe('Checkbox, Radio & Switch components ', () => {
3737 expect ( mockOnChange ) . toHaveBeenCalledWith ( true ) ;
3838 } ) ;
3939
40- it ( "<CheckBox/> shouldn't change value while disabled" , async ( ) => {
40+ it ( "<CheckBox/> shouldn't change value while disabled" , ( ) => {
4141 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
4242 render (
4343 < Checkbox
@@ -49,11 +49,11 @@ describe('Checkbox, Radio & Switch components ', () => {
4949 />
5050 ) ;
5151 expect ( screen . getByTestId ( 'checkbox' ) ) . toBeOnTheScreen ( ) ;
52-
52+ expect ( screen . getByTestId ( 'checkbox' ) ) . toBeDisabled ( ) ;
5353 fireEvent . press ( screen . getByTestId ( 'checkbox' ) ) ;
5454 expect ( mockOnChange ) . toHaveBeenCalledTimes ( 0 ) ;
5555 } ) ;
56- it ( '<CheckBox/> Should render the correct label' , async ( ) => {
56+ it ( '<CheckBox/> Should render the correct label' , ( ) => {
5757 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
5858 render (
5959 < Checkbox
@@ -73,18 +73,18 @@ describe('Checkbox, Radio & Switch components ', () => {
7373 expect ( screen . getByTestId ( 'checkbox' ) . props . accessibilityRole ) . toBe (
7474 'checkbox'
7575 ) ;
76+
7677 expect ( screen . getByTestId ( 'checkbox' ) . props . accessibilityLabel ) . toBe (
7778 'agree'
7879 ) ;
79-
80- expect ( screen . getByTestId ( 'checkbox-label' ) ?. props . children ) . toBe (
80+ expect ( screen . getByTestId ( 'checkbox-label' ) ) . toHaveTextContent (
8181 'I agree to terms and conditions'
8282 ) ;
8383 fireEvent . press ( screen . getByTestId ( 'checkbox' ) ) ;
8484 expect ( mockOnChange ) . toHaveBeenCalledTimes ( 0 ) ;
8585 } ) ;
8686
87- it ( '<Radio /> renders correctly and call on change on Press' , async ( ) => {
87+ it ( '<Radio /> renders correctly and call on change on Press' , ( ) => {
8888 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
8989 render (
9090 < Radio
@@ -96,18 +96,16 @@ describe('Checkbox, Radio & Switch components ', () => {
9696 ) ;
9797 expect ( screen . getByTestId ( 'radio' ) ) . toBeOnTheScreen ( ) ;
9898 expect ( screen . queryByTestId ( 'radio-label' ) ) . not . toBeOnTheScreen ( ) ;
99-
100- expect ( screen . getByTestId ( 'radio' ) . props . accessibilityState . checked ) . toBe (
101- false
102- ) ;
99+ expect ( screen . getByTestId ( 'radio' ) ) . toBeEnabled ( ) ;
100+ expect ( screen . getByTestId ( 'radio' ) ) . not . toBeChecked ( ) ;
103101 expect ( screen . getByTestId ( 'radio' ) . props . accessibilityRole ) . toBe ( 'radio' ) ;
104102 expect ( screen . getByTestId ( 'radio' ) . props . accessibilityLabel ) . toBe ( 'agree' ) ;
105103 fireEvent . press ( screen . getByTestId ( 'radio' ) ) ;
106104 expect ( mockOnChange ) . toHaveBeenCalledTimes ( 1 ) ;
107105 expect ( mockOnChange ) . toHaveBeenCalledWith ( true ) ;
108106 } ) ;
109107
110- it ( '<Radio /> should render the correct label' , async ( ) => {
108+ it ( '<Radio /> should render the correct label' , ( ) => {
111109 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
112110 render (
113111 < Radio
@@ -120,7 +118,7 @@ describe('Checkbox, Radio & Switch components ', () => {
120118 ) ;
121119 expect ( screen . getByTestId ( 'radio' ) ) . toBeOnTheScreen ( ) ;
122120 expect ( screen . getByTestId ( 'radio-label' ) ) . toBeOnTheScreen ( ) ;
123- expect ( screen . getByTestId ( 'radio-label' ) ?. props . children ) . toBe (
121+ expect ( screen . getByTestId ( 'radio-label' ) ) . toHaveTextContent (
124122 'I agree to terms and conditions'
125123 ) ;
126124
@@ -134,7 +132,7 @@ describe('Checkbox, Radio & Switch components ', () => {
134132 expect ( mockOnChange ) . toHaveBeenCalledWith ( true ) ;
135133 } ) ;
136134
137- it ( "<Radio/> shouldn't change value while disabled" , async ( ) => {
135+ it ( "<Radio/> shouldn't change value while disabled" , ( ) => {
138136 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
139137 render (
140138 < Radio
@@ -146,12 +144,12 @@ describe('Checkbox, Radio & Switch components ', () => {
146144 />
147145 ) ;
148146 expect ( screen . getByTestId ( 'radio' ) ) . toBeOnTheScreen ( ) ;
149-
147+ expect ( screen . getByTestId ( 'radio' ) ) . toBeDisabled ( ) ;
150148 fireEvent . press ( screen . getByTestId ( 'radio' ) ) ;
151149 expect ( mockOnChange ) . toHaveBeenCalledTimes ( 0 ) ;
152150 } ) ;
153151
154- it ( '<Switch /> renders correctly and call on change on Press' , async ( ) => {
152+ it ( '<Switch /> renders correctly and call on change on Press' , ( ) => {
155153 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
156154 render (
157155 < Switch
@@ -163,7 +161,7 @@ describe('Checkbox, Radio & Switch components ', () => {
163161 ) ;
164162 expect ( screen . getByTestId ( 'switch' ) ) . toBeOnTheScreen ( ) ;
165163 expect ( screen . queryByTestId ( 'switch-label' ) ) . not . toBeOnTheScreen ( ) ;
166-
164+ expect ( screen . getByTestId ( 'switch' ) ) . toBeEnabled ( ) ;
167165 expect ( screen . getByTestId ( 'switch' ) . props . accessibilityState . checked ) . toBe (
168166 false
169167 ) ;
@@ -174,7 +172,7 @@ describe('Checkbox, Radio & Switch components ', () => {
174172 expect ( mockOnChange ) . toHaveBeenCalledWith ( true ) ;
175173 } ) ;
176174
177- it ( '<Switch /> should render the correct label' , async ( ) => {
175+ it ( '<Switch /> should render the correct label' , ( ) => {
178176 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
179177 render (
180178 < Switch
@@ -187,7 +185,7 @@ describe('Checkbox, Radio & Switch components ', () => {
187185 ) ;
188186 expect ( screen . getByTestId ( 'switch' ) ) . toBeOnTheScreen ( ) ;
189187 expect ( screen . getByTestId ( 'switch-label' ) ) . toBeOnTheScreen ( ) ;
190- expect ( screen . getByTestId ( 'switch-label' ) ?. props . children ) . toBe (
188+ expect ( screen . getByTestId ( 'switch-label' ) ) . toHaveTextContent (
191189 'I agree to terms and conditions'
192190 ) ;
193191 expect ( screen . getByTestId ( 'switch' ) . props . accessibilityState . checked ) . toBe (
@@ -200,7 +198,7 @@ describe('Checkbox, Radio & Switch components ', () => {
200198 expect ( mockOnChange ) . toHaveBeenCalledWith ( true ) ;
201199 } ) ;
202200
203- it ( "<Switch/> shouldn't change value while disabled" , async ( ) => {
201+ it ( "<Switch/> shouldn't change value while disabled" , ( ) => {
204202 const mockOnChange = jest . fn ( ( checked ) => checked ) ;
205203 render (
206204 < Switch
0 commit comments