-
Notifications
You must be signed in to change notification settings - Fork 279
-
I have read the docs.
However, I am still unable to test this properly.
i tried this:
const event = userEvent.setup(); await event.longPress(getByText("Route 2"));
but in this case I don't know what should be the condition to check.
And I tried this too:
fireEvent(getByText("Route 2"), "onLongPress"); expect(mockNavigation.navigate).toHaveBeenCalledWith({ navigation: mockNavigation, targetKey: "route2", });
but this fails as well:
●くろまる TabBar › calls onLongPress when a tab is long-pressed
expect(jest.fn()).toHaveBeenCalledWith(...expected)
Expected: {"navigation": {"emit": [Function mockConstructor], "navigate": [Function mockConstructor]}, "targetKey": "route2"}
Number of calls: 0
131 | // check
132 |
> 133 | expect(mockNavigation.navigate).toHaveBeenCalledWith({
| ^
134 | navigation: mockNavigation,
135 | targetKey: "route2",
136 | });
Any ideas what I am missing? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
update:
I've tried this too, no success:
const event = userEvent.setup(); await event.longPress(getByText("Route 2")); await waitFor(() => { // Expect that onLongPress has been called with the correct arguments expect(mockOnLongPress).toHaveBeenCalledWith({ navigation: mockNavigation, targetKey: "route2", // Adjust the expected target key as needed }); });
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
-
Hello @zilahir, the code you posted should work, I can't tell what could be the problem here, could you provide the full example?
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment