Skip to content

Commit

Permalink
test: update test description to reflect that refetch should be stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ismay committed Apr 5, 2022
1 parent 003fb33 commit f60dfd6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions services/data/src/react/hooks/useDataQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand All @@ -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(() => {
Expand All @@ -467,7 +467,7 @@ describe('useDataQuery', () => {
expect(spy).toHaveBeenCalledTimes(1)

act(() => {
staleRefetch()
initialRefetch()
})

await waitFor(() => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit f60dfd6

Please sign in to comment.