@@ -5,38 +5,51 @@ import { render } from '../.';
5
5
6
6
test ( 'find asynchronously finds elements' , async ( ) => {
7
7
const {
8
- findByA11yLabel ,
8
+ findAllByA11yHint ,
9
9
findAllByA11yLabel,
10
-
11
- findByPlaceholder,
10
+ findAllByA11yRole,
11
+ findAllByA11yStates,
12
+ findAllByA11yTraits,
12
13
findAllByPlaceholder,
13
-
14
- findByText,
14
+ findAllByTestId,
15
15
findAllByText,
16
-
17
- findByValue,
18
16
findAllByValue,
19
-
17
+ findByA11yHint,
18
+ findByA11yLabel,
20
19
findByA11yRole,
21
- findAllByA11yRole,
22
-
20
+ findByA11yStates,
21
+ findByA11yTraits,
22
+ findByPlaceholder,
23
23
findByTestId,
24
- findAllByTestId,
24
+ findByText,
25
+ findByValue,
25
26
} = render (
26
27
< View >
27
28
< Text testID = "test-id" accessibilityRole = "text" >
28
29
test text content
29
30
</ Text >
30
31
< TextInput placeholder = "placeholder" />
31
32
< TextInput value = "value" />
33
+ < TextInput accessibilityStates = { [ 'disabled' ] } />
32
34
< Image accessibilityLabel = "test-label" src = "/lucy-ricardo.png" />
33
- < View role = "dialog" />
35
+ < Image accessibilityHint = "test-hint" src = "/lucy-ricardo.png" />
36
+ < View accessibilityRole = "dialog" />
37
+ < View accessibilityTraits = { [ 'button' ] } />
34
38
</ View > ,
35
39
) ;
36
40
41
+ await expect ( findByA11yHint ( 'test-hint' ) ) . resolves . toBeTruthy ( ) ;
42
+ await expect ( findAllByA11yHint ( 'test-hint' ) ) . resolves . toHaveLength ( 1 ) ;
43
+
37
44
await expect ( findByA11yLabel ( 'test-label' ) ) . resolves . toBeTruthy ( ) ;
38
45
await expect ( findAllByA11yLabel ( 'test-label' ) ) . resolves . toHaveLength ( 1 ) ;
39
46
47
+ await expect ( findByA11yStates ( [ 'disabled' ] ) ) . resolves . toBeTruthy ( ) ;
48
+ await expect ( findAllByA11yStates ( [ 'disabled' ] ) ) . resolves . toHaveLength ( 1 ) ;
49
+
50
+ await expect ( findByA11yTraits ( [ 'button' ] ) ) . resolves . toBeTruthy ( ) ;
51
+ await expect ( findAllByA11yTraits ( [ 'button' ] ) ) . resolves . toHaveLength ( 1 ) ;
52
+
40
53
await expect ( findByPlaceholder ( 'placeholder' ) ) . resolves . toBeTruthy ( ) ;
41
54
await expect ( findAllByPlaceholder ( 'placeholder' ) ) . resolves . toHaveLength ( 1 ) ;
42
55
@@ -55,31 +68,44 @@ test('find asynchronously finds elements', async () => {
55
68
56
69
test ( 'find rejects when something cannot be found' , async ( ) => {
57
70
const {
58
- findByA11yLabel ,
71
+ findAllByA11yHint ,
59
72
findAllByA11yLabel,
60
-
61
- findByPlaceholder,
73
+ findAllByA11yRole,
74
+ findAllByA11yStates,
75
+ findAllByA11yTraits,
62
76
findAllByPlaceholder,
63
-
64
- findByText,
77
+ findAllByTestId,
65
78
findAllByText,
66
-
67
- findByValue,
68
79
findAllByValue,
69
-
80
+ findByA11yHint,
81
+ findByA11yLabel,
70
82
findByA11yRole,
71
- findAllByA11yRole,
72
-
83
+ findByA11yStates,
84
+ findByA11yTraits,
85
+ findByPlaceholder,
73
86
findByTestId,
74
- findAllByTestId,
87
+ findByText,
88
+ findByValue,
75
89
} = render ( < View /> ) ;
76
90
77
91
const qo = { } ;
78
92
const wo = { timeout : 10 } ;
79
93
94
+ await expect ( findByA11yHint ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
95
+ await expect ( findAllByA11yHint ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
96
+
80
97
await expect ( findByA11yLabel ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
81
98
await expect ( findAllByA11yLabel ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
82
99
100
+ await expect ( findByA11yRole ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
101
+ await expect ( findAllByA11yRole ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
102
+
103
+ await expect ( findByA11yStates ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
104
+ await expect ( findAllByA11yStates ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
105
+
106
+ await expect ( findByA11yTraits ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
107
+ await expect ( findAllByA11yTraits ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
108
+
83
109
await expect ( findByPlaceholder ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
84
110
await expect ( findAllByPlaceholder ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
85
111
@@ -89,9 +115,6 @@ test('find rejects when something cannot be found', async () => {
89
115
await expect ( findByValue ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
90
116
await expect ( findAllByValue ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
91
117
92
- await expect ( findByA11yRole ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
93
- await expect ( findAllByA11yRole ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
94
-
95
118
await expect ( findByTestId ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
96
119
await expect ( findAllByTestId ( 'x' , qo , wo ) ) . rejects . toThrow ( 'x' ) ;
97
120
} ) ;
0 commit comments