From cd10c4d89c8d1c2933885e4b76286e406a4e7091 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Fri, 6 Aug 2021 10:25:44 -0400 Subject: [PATCH] more assertions in the partialRefetch stuff --- src/react/hooks/__tests__/useQuery.test.tsx | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/react/hooks/__tests__/useQuery.test.tsx b/src/react/hooks/__tests__/useQuery.test.tsx index cd40ca83bef..7d2e15917ed 100644 --- a/src/react/hooks/__tests__/useQuery.test.tsx +++ b/src/react/hooks/__tests__/useQuery.test.tsx @@ -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); @@ -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);