-
Notifications
You must be signed in to change notification settings - Fork 276
feat: add text match options a.k.a string precision API #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
34ffda8
d95ff2f
b616319
3857870
7c4c074
f9e7d8d
e3719bd
73c6aed
0884d86
c14446c
677a78e
cb6d122
b7f0b74
5f1d266
e5e977b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ test('queryByText nested text across multiple <Text> in <Text>', () => { | |
); | ||
|
||
expect(queryByText('Hello World!')?.props.nativeID).toBe('1'); | ||
expect(queryByText('hello Wo', { exact: false })?.props.nativeID).toBe('1'); | ||
}); | ||
|
||
test('queryByText with nested Text components return the closest Text', () => { | ||
|
@@ -72,6 +73,7 @@ test('queryByText with nested Text components return the closest Text', () => { | |
const { queryByText } = render(<NestedTexts />); | ||
|
||
expect(queryByText('My text')?.props.nativeID).toBe('2'); | ||
expect(queryByText('My text', { exact: false })?.props.nativeID).toBe('2'); | ||
}); | ||
|
||
test('queryByText with nested Text components each with text return the lowest one', () => { | ||
|
@@ -87,6 +89,19 @@ test('queryByText with nested Text components each with text return the lowest o | |
expect(queryByText('My text')?.props.nativeID).toBe('2'); | ||
}); | ||
|
||
test('queryByText with nested Text components each with text return the top one when using not-exact text match', () => { | ||
const NestedTexts = () => ( | ||
<Text nativeID="1"> | ||
bob | ||
<Text nativeID="2">My text</Text> | ||
</Text> | ||
); | ||
|
||
const { queryByText } = render(<NestedTexts />); | ||
|
||
expect(queryByText('My text', { exact: false })?.props.nativeID).toBe('1'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be the opposite? Let's say that I have a onPress handler on the Text of id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On web this test returns the element with |
||
}); | ||
|
||
test('queryByText nested <CustomText> in <Text>', () => { | ||
const CustomText = ({ children }) => { | ||
return <Text>{children}</Text>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this test to pass. This is would be consistent with the web behaviour. It currently fails in this PR.