Skip to content

Commit

Permalink
re-add onSubscriptionData mock to test
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Jan 25, 2022
1 parent f0cd321 commit a565fd5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/react/hooks/__tests__/useSubscription.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ describe('useSubscription Hook', () => {
cache: new Cache({ addTypename: false })
});

const onSubscriptionData = jest.fn();
const { result, unmount, waitForNextUpdate, rerender } = renderHook(
({ variables }) => useSubscription(subscription, {
variables,
skip: true
skip: true,
onSubscriptionData,
}),
{
initialProps: {
Expand All @@ -159,10 +161,11 @@ describe('useSubscription Hook', () => {
expect(result.current.data).toBe(undefined);

rerender({ variables: { foo: 'bar2' }});
expect(onSetup).toHaveBeenCalledTimes(0);

await expect(waitForNextUpdate({ timeout: 20 }))
.rejects.toThrow('Timed out');

expect(onSetup).toHaveBeenCalledTimes(0);
expect(onSubscriptionData).toHaveBeenCalledTimes(0);
unmount();
});

Expand Down

0 comments on commit a565fd5

Please sign in to comment.