-
Notifications
You must be signed in to change notification settings - Fork 274
feat: add findBy*
queries
#304
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
Merged
thymikee
merged 18 commits into
callstack:master
from
mdjastrzebski:feature/findByQueries
May 15, 2020
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fb9f2e4
Basic async findBy queries
mdjastrzebski 8523359
Refactored findBy queries to be built with makeFindQuery
mdjastrzebski ec9d7d0
findBy queries for A11y selectors
mdjastrzebski 69ee9e5
Custom findByTestId implementation that avoids current getByTestId is…
mdjastrzebski 8ac5fc3
Fixed prettier issue
mdjastrzebski 51b9111
Updates Queries.md with findBy queries
mdjastrzebski 7aa159b
Merge branch 'master' into feature/findByQueries
mdjastrzebski 52c3e08
Trying to fix test timeout error appearing only on CI
mdjastrzebski fa622be
Merge branch 'feature/findByQueries' of https://github.com/mdjastrzeb…
mdjastrzebski 97b4aa9
Code review changes
mdjastrzebski d4afa24
Added typescript types & tests
mdjastrzebski 0151092
Removed export of GetByAPI, QueryByAPI and FindByAPI interfaces in TS
mdjastrzebski 0c7c58b
Reversed prettier run on typings
mdjastrzebski d0bb69a
Merge branch 'master' into feature/findByQueries
mdjastrzebski 48559d3
Added overlapping pieces with `within` operator
mdjastrzebski 1c2a653
Small cleanup
mdjastrzebski 4f455b3
Update website/docs/Queries.md
thymikee 77df844
Moved async/await tests to the end of test methods
mdjastrzebski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { View, Text, TextInput } from 'react-native'; | ||
import { render } from '..'; | ||
|
||
test('findBy queries work asynchronously', async () => { | ||
const options = { timeout: 10 }; // Short timeout so that this test runs quickly | ||
const { | ||
rerender, | ||
findByTestId, | ||
findAllByTestId, | ||
findByText, | ||
findAllByText, | ||
findByPlaceholder, | ||
findAllByPlaceholder, | ||
findByDisplayValue, | ||
findAllByDisplayValue, | ||
} = render(<View />); | ||
await expect(findByTestId('aTestId', options)).rejects.toBeTruthy(); | ||
await expect(findAllByTestId('aTestId', options)).rejects.toBeTruthy(); | ||
await expect(findByText('Some Text', options)).rejects.toBeTruthy(); | ||
await expect(findAllByText('Some Text', options)).rejects.toBeTruthy(); | ||
await expect( | ||
findByPlaceholder('Placeholder Text', options) | ||
).rejects.toBeTruthy(); | ||
await expect( | ||
findAllByPlaceholder('Placeholder Text', options) | ||
).rejects.toBeTruthy(); | ||
await expect( | ||
findByDisplayValue('Display Value', options) | ||
).rejects.toBeTruthy(); | ||
await expect( | ||
findAllByDisplayValue('Display Value', options) | ||
).rejects.toBeTruthy(); | ||
|
||
setTimeout( | ||
() => | ||
rerender( | ||
<View testID="aTestId"> | ||
<Text>Some Text</Text> | ||
<TextInput placeholder="Placeholder Text" /> | ||
<TextInput value="Display Value" /> | ||
</View> | ||
), | ||
20 | ||
); | ||
|
||
await expect(findByTestId('aTestId')).resolves.toBeTruthy(); | ||
await expect(findAllByTestId('aTestId')).resolves.toHaveLength(1); | ||
await expect(findByText('Some Text')).resolves.toBeTruthy(); | ||
await expect(findAllByText('Some Text')).resolves.toHaveLength(1); | ||
await expect(findByPlaceholder('Placeholder Text')).resolves.toBeTruthy(); | ||
await expect(findAllByPlaceholder('Placeholder Text')).resolves.toHaveLength( | ||
1 | ||
); | ||
await expect(findByDisplayValue('Display Value')).resolves.toBeTruthy(); | ||
await expect(findAllByDisplayValue('Display Value')).resolves.toHaveLength(1); | ||
}, 10000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.