Skip to content

Commit

Permalink
more assertions in the partialRefetch stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
brainkim committed Aug 6, 2021
1 parent 2f28e31 commit 95422e1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/react/hooks/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2183,9 +2183,21 @@ describe('useQuery Hook', () => {
expect(result.current.data).toBe(undefined);
expect(result.current.networkStatus).toBe(NetworkStatus.loading);

const updates = result.all.length;
await waitForNextUpdate();
expect(result.all.length - updates).toBe(2);
// waitForUpdate seems to miss the erroring render
const previous = result.all[result.all.length - 2];
if (previous instanceof Error) {
throw previous;
}

expect(previous.loading).toBe(true);
expect(previous.error).toBe(undefined);
expect(previous.data).toBe(undefined);

expect(result.current.loading).toBe(true);
expect(result.current.error).toBe(undefined);
expect(result.current.data).toBe(undefined);
expect(result.current.networkStatus).toBe(NetworkStatus.refetch);

Expand Down Expand Up @@ -2240,8 +2252,19 @@ describe('useQuery Hook', () => {
expect(result.current.data).toBe(undefined);
expect(result.current.networkStatus).toBe(NetworkStatus.loading);

const updates = result.all.length;
await waitForNextUpdate();
expect(result.all.length - updates).toBe(2);
// waitForUpdate seems to miss the erroring render
const previous = result.all[result.all.length - 2];
if (previous instanceof Error) {
throw previous;
}

expect(previous.loading).toBe(true);
expect(previous.error).toBe(undefined);
expect(previous.data).toBe(undefined);

expect(result.current.loading).toBe(true);
expect(result.current.data).toBe(undefined);
expect(result.current.networkStatus).toBe(NetworkStatus.refetch);
Expand Down

0 comments on commit 95422e1

Please sign in to comment.