Skip to content

Commit cdb7093

Browse files
committed
chore: rebase on main
1 parent 09d8925 commit cdb7093

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@
8686
},
8787
"jest": {
8888
"preset": "./jest-preset",
89-
"setupFilesAfterEnv": ["./jest-setup.ts"],
89+
"setupFilesAfterEnv": [
90+
"./jest-setup.ts"
91+
],
9092
"testPathIgnorePatterns": [
9193
"timerUtils",
9294
"examples/"

src/queries/__tests__/text.breaking.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,5 @@ test('byText support hidden option', () => {
510510

511511
test('byText should return host component', () => {
512512
const { getByText } = render(<Text>hello</Text>);
513-
514513
expect(getByText('hello').type).toBe('Text');
515514
});

src/queries/__tests__/text.test.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
TextInput,
99
} from 'react-native';
1010
import { render, getDefaultNormalizer, within } from '../..';
11+
import { getConfig } from '../../config';
1112

1213
test('byText matches simple text', () => {
1314
const { getByText } = render(<Text testID="text">Hello World</Text>);
@@ -504,7 +505,10 @@ test('byText support hidden option', () => {
504505
});
505506

506507
test('byText should return composite Text', () => {
508+
const textType = getConfig().useBreakingChanges
509+
? getHostComponentNames().text
510+
: Text;
511+
console.log('BB', getConfig().useBreakingChanges, textType);
507512
const { getByText } = render(<Text>hello</Text>);
508-
509513
expect(getByText('hello').type).toBe(Text);
510514
});

src/queries/text.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import type { ReactTestInstance } from 'react-test-renderer';
22
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';
74
import {
85
getCompositeParentOfType,
96
isHostElementForType,
107
} 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';
1213
import { makeQueries } from './makeQueries';
1314
import type {
1415
FindAllByQuery,
@@ -19,7 +20,10 @@ import type {
1920
QueryByQuery,
2021
} from './makeQueries';
2122
import type { CommonQueryOptions } from './options';
22-
import { getHostComponentNames } from '../helpers/host-component-names';
23+
24+
beforeEach(() => {
25+
resetToDefaults();
26+
});
2327

2428
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
2529

@@ -41,21 +45,20 @@ const queryAllByText = (
4145

4246
const results = findAll(
4347
baseInstance,
44-
(node) => matchTextContent(node, text, options),
48+
(node) =>
49+
filterNodeByType(node, Text) && matchTextContent(node, text, options),
4550
{ ...options, matchDeepestOnly: true }
4651
);
4752

4853
return results;
4954
}
5055

5156
// vNext version: returns host Text
52-
const textType = getConfig().useBreakingChanges
53-
? getHostComponentNames().text
54-
: Text;
55-
5657
return findAll(
5758
instance,
58-
(node) => node.type === textType && matchTextContent(node, text, options),
59+
(node) =>
60+
filterNodeByType(node, getHostComponentNames().text) &&
61+
matchTextContent(node, text, options),
5962
{
6063
...options,
6164
matchDeepestOnly: true,

0 commit comments

Comments
 (0)