11import type { ReactTestInstance } from 'react-test-renderer' ;
2- import { TextMatch } from '../matches' ;
3- import { matchStringProp } from '../helpers/matchers/matchStringProp' ;
2+ import { matches , TextMatch } from '../matches' ;
43import { makeQueries } from './makeQueries' ;
54import type {
65 FindAllByQuery ,
@@ -10,15 +9,28 @@ import type {
109 QueryAllByQuery ,
1110 QueryByQuery ,
1211} from './makeQueries' ;
12+ import { TextMatchOptions } from './text' ;
13+
14+ const getNodeByHintText = (
15+ node : ReactTestInstance ,
16+ text : TextMatch ,
17+ options : TextMatchOptions = { }
18+ ) => {
19+ const { exact, normalizer } = options ;
20+ return matches ( text , node . props . accessibilityHint , normalizer , exact ) ;
21+ } ;
1322
1423const queryAllByHintText = (
1524 instance : ReactTestInstance
16- ) : ( ( hint : TextMatch ) => Array < ReactTestInstance > ) =>
17- function queryAllByA11yHintFn ( hint ) {
25+ ) : ( (
26+ hint : TextMatch ,
27+ queryOptions ?: TextMatchOptions
28+ ) => Array < ReactTestInstance > ) =>
29+ function queryAllByA11yHintFn ( hint , queryOptions ) {
1830 return instance . findAll (
1931 ( node ) =>
2032 typeof node . type === 'string' &&
21- matchStringProp ( node . props . accessibilityHint , hint )
33+ getNodeByHintText ( node , hint , queryOptions )
2234 ) ;
2335 } ;
2436
@@ -34,28 +46,28 @@ const { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(
3446) ;
3547
3648export type ByHintTextQueries = {
37- getByHintText : GetByQuery < TextMatch > ;
38- getAllByHintText : GetAllByQuery < TextMatch > ;
39- queryByHintText : QueryByQuery < TextMatch > ;
40- queryAllByHintText : QueryAllByQuery < TextMatch > ;
41- findByHintText : FindByQuery < TextMatch > ;
42- findAllByHintText : FindAllByQuery < TextMatch > ;
49+ getByHintText : GetByQuery < TextMatch , TextMatchOptions > ;
50+ getAllByHintText : GetAllByQuery < TextMatch , TextMatchOptions > ;
51+ queryByHintText : QueryByQuery < TextMatch , TextMatchOptions > ;
52+ queryAllByHintText : QueryAllByQuery < TextMatch , TextMatchOptions > ;
53+ findByHintText : FindByQuery < TextMatch , TextMatchOptions > ;
54+ findAllByHintText : FindAllByQuery < TextMatch , TextMatchOptions > ;
4355
4456 // a11yHint aliases
45- getByA11yHint : GetByQuery < TextMatch > ;
46- getAllByA11yHint : GetAllByQuery < TextMatch > ;
47- queryByA11yHint : QueryByQuery < TextMatch > ;
48- queryAllByA11yHint : QueryAllByQuery < TextMatch > ;
49- findByA11yHint : FindByQuery < TextMatch > ;
50- findAllByA11yHint : FindAllByQuery < TextMatch > ;
57+ getByA11yHint : GetByQuery < TextMatch , TextMatchOptions > ;
58+ getAllByA11yHint : GetAllByQuery < TextMatch , TextMatchOptions > ;
59+ queryByA11yHint : QueryByQuery < TextMatch , TextMatchOptions > ;
60+ queryAllByA11yHint : QueryAllByQuery < TextMatch , TextMatchOptions > ;
61+ findByA11yHint : FindByQuery < TextMatch , TextMatchOptions > ;
62+ findAllByA11yHint : FindAllByQuery < TextMatch , TextMatchOptions > ;
5163
5264 // accessibilityHint aliases
53- getByAccessibilityHint : GetByQuery < TextMatch > ;
54- getAllByAccessibilityHint : GetAllByQuery < TextMatch > ;
55- queryByAccessibilityHint : QueryByQuery < TextMatch > ;
56- queryAllByAccessibilityHint : QueryAllByQuery < TextMatch > ;
57- findByAccessibilityHint : FindByQuery < TextMatch > ;
58- findAllByAccessibilityHint : FindAllByQuery < TextMatch > ;
65+ getByAccessibilityHint : GetByQuery < TextMatch , TextMatchOptions > ;
66+ getAllByAccessibilityHint : GetAllByQuery < TextMatch , TextMatchOptions > ;
67+ queryByAccessibilityHint : QueryByQuery < TextMatch , TextMatchOptions > ;
68+ queryAllByAccessibilityHint : QueryAllByQuery < TextMatch , TextMatchOptions > ;
69+ findByAccessibilityHint : FindByQuery < TextMatch , TextMatchOptions > ;
70+ findAllByAccessibilityHint : FindAllByQuery < TextMatch , TextMatchOptions > ;
5971} ;
6072
6173export const bindByHintTextQueries = (
0 commit comments