From f60dfd6ef7d096edad1dd89216efe48298b4839d Mon Sep 17 00:00:00 2001 From: ismay <7355199+ismay@users.noreply.github.com> Date: Tue, 5 Apr 2022 14:54:23 +0200 Subject: [PATCH] test: update test description to reflect that refetch should be stable --- services/data/src/react/hooks/useDataQuery.test.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/data/src/react/hooks/useDataQuery.test.tsx b/services/data/src/react/hooks/useDataQuery.test.tsx index 0b515f2e..13945926 100644 --- a/services/data/src/react/hooks/useDataQuery.test.tsx +++ b/services/data/src/react/hooks/useDataQuery.test.tsx @@ -426,7 +426,7 @@ describe('useDataQuery', () => { }) describe('return values: refetch', () => { - it('Should trigger a request for identical variables even if stale', async () => { + it('Should be stable if the query variables change', async () => { let count = 0 const spy = jest.fn(() => { count++ @@ -451,9 +451,9 @@ describe('useDataQuery', () => { expect(spy).not.toHaveBeenCalled() - const staleRefetch = result.current.refetch + const initialRefetch = result.current.refetch act(() => { - staleRefetch() + initialRefetch() }) await waitFor(() => { @@ -467,7 +467,7 @@ describe('useDataQuery', () => { expect(spy).toHaveBeenCalledTimes(1) act(() => { - staleRefetch() + initialRefetch() }) await waitFor(() => { @@ -479,6 +479,7 @@ describe('useDataQuery', () => { }) expect(spy).toHaveBeenCalledTimes(2) + expect(initialRefetch).toBe(result.current.refetch) }) it('Should only trigger a single request when refetch is called on a lazy query with new variables', async () => {