Skip to content

Commit

Permalink
test: refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Feb 5, 2024
1 parent 85e8602 commit e3f6dea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/use-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,18 @@ describe('useQuery', () => {
await runTimers()
expect(wrapper.vm.error).toEqual(null)
})

it('refreshes if it failed no matter the staleTime', async () => {
const query = vi.fn().mockRejectedValue(new Error('fail'))
const { wrapper } = mountDynamicKey({ staleTime: 1000, query: query })

await runTimers()
expect(query).toHaveBeenCalledTimes(1)

wrapper.vm.refresh()
await runTimers()
expect(query).toHaveBeenCalledTimes(2)
})
})

describe('shared state', () => {
Expand Down

0 comments on commit e3f6dea

Please sign in to comment.