1
1
import type { ReactTestInstance } from 'react-test-renderer' ;
2
2
import { Text } from 'react-native' ;
3
- import { findAll } from '../helpers/findAll' ;
4
- import { filterNodeByType } from '../helpers/filterNodeByType' ;
5
- import { matchTextContent } from '../helpers/matchers/matchTextContent' ;
6
- import { TextMatch , TextMatchOptions } from '../matches' ;
3
+ import { getConfig , resetToDefaults } from '../config' ;
7
4
import {
8
5
getCompositeParentOfType ,
9
6
isHostElementForType ,
10
7
} from '../helpers/component-tree' ;
11
- import { getConfig } from '../config' ;
8
+ import { filterNodeByType } from '../helpers/filterNodeByType' ;
9
+ import { findAll } from '../helpers/findAll' ;
10
+ import { getHostComponentNames } from '../helpers/host-component-names' ;
11
+ import { matchTextContent } from '../helpers/matchers/matchTextContent' ;
12
+ import { TextMatch , TextMatchOptions } from '../matches' ;
12
13
import { makeQueries } from './makeQueries' ;
13
14
import type {
14
15
FindAllByQuery ,
@@ -19,7 +20,10 @@ import type {
19
20
QueryByQuery ,
20
21
} from './makeQueries' ;
21
22
import type { CommonQueryOptions } from './options' ;
22
- import { getHostComponentNames } from '../helpers/host-component-names' ;
23
+
24
+ beforeEach ( ( ) => {
25
+ resetToDefaults ( ) ;
26
+ } ) ;
23
27
24
28
type ByTextOptions = CommonQueryOptions & TextMatchOptions ;
25
29
@@ -41,21 +45,20 @@ const queryAllByText = (
41
45
42
46
const results = findAll (
43
47
baseInstance ,
44
- ( node ) => matchTextContent ( node , text , options ) ,
48
+ ( node ) =>
49
+ filterNodeByType ( node , Text ) && matchTextContent ( node , text , options ) ,
45
50
{ ...options , matchDeepestOnly : true }
46
51
) ;
47
52
48
53
return results ;
49
54
}
50
55
51
56
// vNext version: returns host Text
52
- const textType = getConfig ( ) . useBreakingChanges
53
- ? getHostComponentNames ( ) . text
54
- : Text ;
55
-
56
57
return findAll (
57
58
instance ,
58
- ( node ) => node . type === textType && matchTextContent ( node , text , options ) ,
59
+ ( node ) =>
60
+ filterNodeByType ( node , getHostComponentNames ( ) . text ) &&
61
+ matchTextContent ( node , text , options ) ,
59
62
{
60
63
...options ,
61
64
matchDeepestOnly : true ,
0 commit comments