@@ -14,19 +14,25 @@ describe('isHiddenFromAccessibility', () => {
14
14
test ( 'returns false for accessible elements' , ( ) => {
15
15
expect (
16
16
isHiddenFromAccessibility (
17
- render ( < View testID = "subject" /> ) . getByTestId ( 'subject' )
17
+ render ( < View testID = "subject" /> ) . getByTestId ( 'subject' , {
18
+ includeHiddenElements : true ,
19
+ } )
18
20
)
19
21
) . toBe ( false ) ;
20
22
21
23
expect (
22
24
isHiddenFromAccessibility (
23
- render ( < Text testID = "subject" > Hello</ Text > ) . getByTestId ( 'subject' )
25
+ render ( < Text testID = "subject" > Hello</ Text > ) . getByTestId ( 'subject' , {
26
+ includeHiddenElements : true ,
27
+ } )
24
28
)
25
29
) . toBe ( false ) ;
26
30
27
31
expect (
28
32
isHiddenFromAccessibility (
29
- render ( < TextInput testID = "subject" /> ) . getByTestId ( 'subject' )
33
+ render ( < TextInput testID = "subject" /> ) . getByTestId ( 'subject' , {
34
+ includeHiddenElements : true ,
35
+ } )
30
36
)
31
37
) . toBe ( false ) ;
32
38
} ) ;
@@ -37,7 +43,13 @@ describe('isHiddenFromAccessibility', () => {
37
43
38
44
test ( 'detects elements with accessibilityElementsHidden prop' , ( ) => {
39
45
const view = render ( < View testID = "subject" accessibilityElementsHidden /> ) ;
40
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
46
+ expect (
47
+ isHiddenFromAccessibility (
48
+ view . getByTestId ( 'subject' , {
49
+ includeHiddenElements : true ,
50
+ } )
51
+ )
52
+ ) . toBe ( true ) ;
41
53
} ) ;
42
54
43
55
test ( 'detects nested elements with accessibilityElementsHidden prop' , ( ) => {
@@ -46,7 +58,13 @@ describe('isHiddenFromAccessibility', () => {
46
58
< View testID = "subject" />
47
59
</ View >
48
60
) ;
49
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
61
+ expect (
62
+ isHiddenFromAccessibility (
63
+ view . getByTestId ( 'subject' , {
64
+ includeHiddenElements : true ,
65
+ } )
66
+ )
67
+ ) . toBe ( true ) ;
50
68
} ) ;
51
69
52
70
test ( 'detects deeply nested elements with accessibilityElementsHidden prop' , ( ) => {
@@ -59,14 +77,26 @@ describe('isHiddenFromAccessibility', () => {
59
77
</ View >
60
78
</ View >
61
79
) ;
62
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
80
+ expect (
81
+ isHiddenFromAccessibility (
82
+ view . getByTestId ( 'subject' , {
83
+ includeHiddenElements : true ,
84
+ } )
85
+ )
86
+ ) . toBe ( true ) ;
63
87
} ) ;
64
88
65
89
test ( 'detects elements with importantForAccessibility="no-hide-descendants" prop' , ( ) => {
66
90
const view = render (
67
91
< View testID = "subject" importantForAccessibility = "no-hide-descendants" />
68
92
) ;
69
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
93
+ expect (
94
+ isHiddenFromAccessibility (
95
+ view . getByTestId ( 'subject' , {
96
+ includeHiddenElements : true ,
97
+ } )
98
+ )
99
+ ) . toBe ( true ) ;
70
100
} ) ;
71
101
72
102
test ( 'detects nested elements with importantForAccessibility="no-hide-descendants" prop' , ( ) => {
@@ -75,12 +105,24 @@ describe('isHiddenFromAccessibility', () => {
75
105
< View testID = "subject" />
76
106
</ View >
77
107
) ;
78
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
108
+ expect (
109
+ isHiddenFromAccessibility (
110
+ view . getByTestId ( 'subject' , {
111
+ includeHiddenElements : true ,
112
+ } )
113
+ )
114
+ ) . toBe ( true ) ;
79
115
} ) ;
80
116
81
117
test ( 'detects elements with display=none' , ( ) => {
82
118
const view = render ( < View testID = "subject" style = { { display : 'none' } } /> ) ;
83
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
119
+ expect (
120
+ isHiddenFromAccessibility (
121
+ view . getByTestId ( 'subject' , {
122
+ includeHiddenElements : true ,
123
+ } )
124
+ )
125
+ ) . toBe ( true ) ;
84
126
} ) ;
85
127
86
128
test ( 'detects nested elements with display=none' , ( ) => {
@@ -89,7 +131,13 @@ describe('isHiddenFromAccessibility', () => {
89
131
< View testID = "subject" />
90
132
</ View >
91
133
) ;
92
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
134
+ expect (
135
+ isHiddenFromAccessibility (
136
+ view . getByTestId ( 'subject' , {
137
+ includeHiddenElements : true ,
138
+ } )
139
+ )
140
+ ) . toBe ( true ) ;
93
141
} ) ;
94
142
95
143
test ( 'detects deeply nested elements with display=none' , ( ) => {
@@ -102,7 +150,13 @@ describe('isHiddenFromAccessibility', () => {
102
150
</ View >
103
151
</ View >
104
152
) ;
105
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
153
+ expect (
154
+ isHiddenFromAccessibility (
155
+ view . getByTestId ( 'subject' , {
156
+ includeHiddenElements : true ,
157
+ } )
158
+ )
159
+ ) . toBe ( true ) ;
106
160
} ) ;
107
161
108
162
test ( 'detects elements with display=none with complex style' , ( ) => {
@@ -116,12 +170,24 @@ describe('isHiddenFromAccessibility', () => {
116
170
] }
117
171
/>
118
172
) ;
119
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
173
+ expect (
174
+ isHiddenFromAccessibility (
175
+ view . getByTestId ( 'subject' , {
176
+ includeHiddenElements : true ,
177
+ } )
178
+ )
179
+ ) . toBe ( true ) ;
120
180
} ) ;
121
181
122
182
test ( 'is not trigged by opacity = 0' , ( ) => {
123
183
const view = render ( < View testID = "subject" style = { { opacity : 0 } } /> ) ;
124
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( false ) ;
184
+ expect (
185
+ isHiddenFromAccessibility (
186
+ view . getByTestId ( 'subject' , {
187
+ includeHiddenElements : true ,
188
+ } )
189
+ )
190
+ ) . toBe ( false ) ;
125
191
} ) ;
126
192
127
193
test ( 'detects siblings of element with accessibilityViewIsModal prop' , ( ) => {
@@ -131,7 +197,13 @@ describe('isHiddenFromAccessibility', () => {
131
197
< View testID = "subject" />
132
198
</ View >
133
199
) ;
134
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
200
+ expect (
201
+ isHiddenFromAccessibility (
202
+ view . getByTestId ( 'subject' , {
203
+ includeHiddenElements : true ,
204
+ } )
205
+ )
206
+ ) . toBe ( true ) ;
135
207
} ) ;
136
208
137
209
test ( 'detects deeply nested siblings of element with accessibilityViewIsModal prop' , ( ) => {
@@ -145,7 +217,13 @@ describe('isHiddenFromAccessibility', () => {
145
217
</ View >
146
218
</ View >
147
219
) ;
148
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( true ) ;
220
+ expect (
221
+ isHiddenFromAccessibility (
222
+ view . getByTestId ( 'subject' , {
223
+ includeHiddenElements : true ,
224
+ } )
225
+ )
226
+ ) . toBe ( true ) ;
149
227
} ) ;
150
228
151
229
test ( 'is not triggered for element with accessibilityViewIsModal prop' , ( ) => {
@@ -154,7 +232,13 @@ describe('isHiddenFromAccessibility', () => {
154
232
< View accessibilityViewIsModal testID = "subject" />
155
233
</ View >
156
234
) ;
157
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( false ) ;
235
+ expect (
236
+ isHiddenFromAccessibility (
237
+ view . getByTestId ( 'subject' , {
238
+ includeHiddenElements : true ,
239
+ } )
240
+ )
241
+ ) . toBe ( false ) ;
158
242
} ) ;
159
243
160
244
test ( 'is not triggered for child of element with accessibilityViewIsModal prop' , ( ) => {
@@ -165,7 +249,13 @@ describe('isHiddenFromAccessibility', () => {
165
249
</ View >
166
250
</ View >
167
251
) ;
168
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( false ) ;
252
+ expect (
253
+ isHiddenFromAccessibility (
254
+ view . getByTestId ( 'subject' , {
255
+ includeHiddenElements : true ,
256
+ } )
257
+ )
258
+ ) . toBe ( false ) ;
169
259
} ) ;
170
260
171
261
test ( 'is not triggered for descendent of element with accessibilityViewIsModal prop' , ( ) => {
@@ -180,7 +270,13 @@ describe('isHiddenFromAccessibility', () => {
180
270
</ View >
181
271
</ View >
182
272
) ;
183
- expect ( isHiddenFromAccessibility ( view . getByTestId ( 'subject' ) ) ) . toBe ( false ) ;
273
+ expect (
274
+ isHiddenFromAccessibility (
275
+ view . getByTestId ( 'subject' , {
276
+ includeHiddenElements : true ,
277
+ } )
278
+ )
279
+ ) . toBe ( false ) ;
184
280
} ) ;
185
281
186
282
test ( 'has isInaccessible alias' , ( ) => {
0 commit comments