File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,27 @@ describe('supports TextMatch options', () => {
342
342
expect ( getAllByTestId ( 'test' , { exact : false } ) ) . toHaveLength ( 2 ) ;
343
343
} ) ;
344
344
345
+ test ( 'getByHintText, getByHintText' , ( ) => {
346
+ const { getByHintText, getAllByHintText } = render (
347
+ < View >
348
+ < View accessibilityHint = "test" />
349
+ < View accessibilityHint = "tests id" />
350
+ </ View >
351
+ ) ;
352
+ expect ( getByHintText ( 'id' , { exact : false } ) ) . toBeTruthy ( ) ;
353
+ expect ( getAllByHintText ( 'test' , { exact : false } ) ) . toHaveLength ( 2 ) ;
354
+ } ) ;
355
+ test ( 'getByHintText, getByHintText and exact = true' , ( ) => {
356
+ const { queryByHintText, getAllByHintText } = render (
357
+ < View >
358
+ < View accessibilityHint = "test" />
359
+ < View accessibilityHint = "tests id" />
360
+ </ View >
361
+ ) ;
362
+ expect ( queryByHintText ( 'id' , { exact : true } ) ) . toBeNull ( ) ;
363
+ expect ( getAllByHintText ( 'test' , { exact : true } ) ) . toHaveLength ( 1 ) ;
364
+ } ) ;
365
+
345
366
test ( 'with TextMatch option exact === false text search is NOT case sensitive' , ( ) => {
346
367
const { getByText, getAllByText } = render (
347
368
< View >
Original file line number Diff line number Diff line change @@ -27,9 +27,11 @@ const queryAllByHintText = (
27
27
queryOptions ?: TextMatchOptions
28
28
) => Array < ReactTestInstance > ) =>
29
29
function queryAllByA11yHintFn ( hint , queryOptions ) {
30
- return instance
31
- . findAll ( ( node ) => getNodeByHintText ( node , hint , queryOptions ) )
32
- . filter ( ( element ) => typeof element . type === 'string' ) ;
30
+ return instance . findAll (
31
+ ( node ) =>
32
+ typeof node . type === 'string' &&
33
+ getNodeByHintText ( node , hint , queryOptions )
34
+ ) ;
33
35
} ;
34
36
35
37
const getMultipleError = ( hint : TextMatch ) =>
You can’t perform that action at this time.
0 commit comments