Skip to content

Commit

Permalink
fix: usePanGestureProxy.test: add a test to ensure the console.error …
Browse files Browse the repository at this point in the history
…was not called
  • Loading branch information
nmassey committed Mar 25, 2024
1 parent 17d3871 commit 2a66e99
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/hooks/usePanGestureProxy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ describe("Using RNGH v2 gesture API", () => {
expect.objectContaining({ translationX: 20 }),
);
});

it("does not include console.error in the output", () => {
// if react-native-gesture-handler detects that some handlers are
// workletized and some are not, it will log an error to the
// console. We'd like to make sure that this doesn't happen.

// The error that would be shown looks like:
// [react-native-gesture-handler] Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.

const panHandlers = mockedEventHandlers();
const panHandlersFromUser = mockedEventHandlersFromUser();

jest.spyOn(console, "error");

render(<SingleHandler handlers={panHandlers} handlersFromUser={panHandlersFromUser} treatStartAsUpdate />);
fireGestureHandler<PanGesture>(getByGestureTestId("pan"), [
{ state: State.BEGAN },
{ state: State.ACTIVE },
{ state: State.END },
]);

expect(console.error).not.toBeCalled();
});
});

describe("Event list validation", () => {
Expand Down

0 comments on commit 2a66e99

Please sign in to comment.