-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Handle testID prop
#3838
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
Open
m-bert
wants to merge
49
commits into
next
Choose a base branch
from
@mbert/test-ID
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Handle testID prop
#3838
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
dad2eaa
new file
m-bert 6dbc10d
use native
m-bert 4f1dcaa
Buttons
m-bert 8ccf267
Remove Reanimated
m-bert df3f1fb
Components
m-bert a1da35a
Add proper values to relations
m-bert a680461
Bring back old components
m-bert a0d0240
Deprecate legacy buttons
m-bert ef1e736
Deprecate legacy components
m-bert 563fab3
Export new components
m-bert 0f40c58
Add web file
m-bert 13951df
Merge branch 'next' into @mbert/components-new-api
m-bert b77cc2b
Update import
m-bert c336453
use ref in check
m-bert c3f4320
Correct refs
m-bert c6c83ba
Merge branch 'next' into @mbert/components-new-api
m-bert 86c38f3
Merge branch 'next' into @mbert/components-new-api
m-bert baf7eb1
Merge branch 'next' into @mbert/components-new-api
m-bert c8f7c8c
Add examples
m-bert 2a356f8
Fix buttons
m-bert 73969da
Yet another fix
m-bert f4fa5f6
Remove Drawer Layout
m-bert ede51fe
Impoort hooks directly
m-bert d34ef86
remove import
m-bert fdf9533
Update examples
m-bert 38f36fe
Merge branch 'next' into @mbert/components-new-api
m-bert 25bd430
Update scroll example
m-bert 4c5eaf8
Correctly attach NativeViewGestureHandler
m-bert 36d1afb
Fix relations in ScrollView
m-bert 11eeef1
FlatList
m-bert 753d43b
Merge branch 'next' into @mbert/components-new-api
m-bert 9b4743a
Import hooks directly
m-bert f04d434
Fixes
m-bert 1f77201
Update example
m-bert b491534
Update Scroll ref
m-bert 0ea974e
Correct web initialization
m-bert 03b8a0f
Remove comment
m-bert 5a6dc60
Do not unpack rippleColor
m-bert 0ce2be8
Remove testID
m-bert 23403fa
Remove testID from cnw
m-bert b7c461d
Disbale reanimated for components
m-bert c31dba4
Add gestures to registry
m-bert cad5d35
Jest works
m-bert f165966
Change testId to testID
m-bert 464699e
Update packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts
m-bert 015e285
Merge branch 'next' into @mbert/test-ID
m-bert fbfa333
new line
m-bert 57db777
Add tests to github workflow
m-bert 6b7fff0
Store handlers only in jest
m-bert 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
60 changes: 60 additions & 0 deletions
60
packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx
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,60 @@ | ||
| import { usePanGesture } from '../v3/hooks/gestures'; | ||
| import { render, renderHook } from '@testing-library/react-native'; | ||
| import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; | ||
| import { State } from '../State'; | ||
| import GestureHandlerRootView from '../components/GestureHandlerRootView'; | ||
| import { RectButton } from '../v3/components'; | ||
| import { act } from 'react'; | ||
|
|
||
| describe('[API v3] Hooks', () => { | ||
| test('Pan gesture', () => { | ||
| const onBegin = jest.fn(); | ||
| const onStart = jest.fn(); | ||
|
|
||
| const panGesture = renderHook(() => | ||
| usePanGesture({ | ||
| disableReanimated: true, | ||
| onBegin: (e) => onBegin(e), | ||
| onActivate: (e) => onStart(e), | ||
| }) | ||
| ).result.current; | ||
|
|
||
| fireGestureHandler(panGesture, [ | ||
| { oldState: State.UNDETERMINED, state: State.BEGAN }, | ||
| { oldState: State.BEGAN, state: State.ACTIVE }, | ||
| { oldState: State.ACTIVE, state: State.ACTIVE }, | ||
| { oldState: State.ACTIVE, state: State.END }, | ||
| ]); | ||
|
|
||
| expect(onBegin).toHaveBeenCalledTimes(1); | ||
| expect(onStart).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('[API v3] Components', () => { | ||
| test('Rect Button', () => { | ||
| const pressFn = jest.fn(); | ||
|
|
||
| const RectButtonExample = () => { | ||
| return ( | ||
| <GestureHandlerRootView> | ||
| <RectButton testID="btn" onPress={pressFn} /> | ||
| </GestureHandlerRootView> | ||
| ); | ||
| }; | ||
|
|
||
| render(<RectButtonExample />); | ||
|
|
||
| const nativeGesture = getByGestureTestId('btn'); | ||
|
|
||
| act(() => { | ||
| fireGestureHandler(nativeGesture, [ | ||
| { oldState: State.UNDETERMINED, state: State.BEGAN }, | ||
| { oldState: State.BEGAN, state: State.ACTIVE }, | ||
| { oldState: State.ACTIVE, state: State.END }, | ||
| ]); | ||
| }); | ||
|
|
||
| expect(pressFn).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
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
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
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.