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 cd10c4d
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);

expect(result.all.length).toBe(1);
await waitForNextUpdate();
// waitForUpdate seems to miss the erroring render
expect(result.all.length).toBe(3);
const previous = result.all[1];
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);

expect(result.all.length).toBe(1);
await waitForNextUpdate();
// waitForUpdate seems to miss the erroring render
expect(result.all.length).toBe(3);
const previous = result.all[1];
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 cd10c4d

Please sign in to comment.