Skip to content

Commit

Permalink
test: todos
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jan 10, 2024
1 parent c15c7e5 commit 0b4c1fc
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/use-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('useQuery', () => {
expect(wrapper.vm.error).toEqual(new Error('foo'))
})

it('skips fetching if initial data is present in store', async () => {
it.todo('skips fetching if initial data is present in store', async () => {
const pinia = createPinia()
const status = shallowRef<UseQueryStatus>('pending')

Expand Down Expand Up @@ -303,28 +303,31 @@ describe('useQuery', () => {
})
}

it('refreshes the data even with initial values after staleTime is elapsed', async () => {
const pinia = createPinia()
pinia.state.value.PiniaColada = {
entryStateRegistry: shallowReactive(new TreeMapNode(['key'], 60)),
it.todo(
'refreshes the data even with initial values after staleTime is elapsed',
async () => {
const pinia = createPinia()
pinia.state.value.PiniaColada = {
entryStateRegistry: shallowReactive(new TreeMapNode(['key'], 60)),
}
const { wrapper, fetcher } = mountSimple(
{
staleTime: 100,
},
{}
)

await runTimers()
expect(wrapper.vm.data).toBe(60)
expect(fetcher).toHaveBeenCalledTimes(0)

await vi.advanceTimersByTime(101)
wrapper.vm.refresh()
await runTimers()
expect(wrapper.vm.data).toBe(42)
expect(fetcher).toHaveBeenCalledTimes(1)
}
const { wrapper, fetcher } = mountSimple(
{
staleTime: 100,
},
{}
)

await runTimers()
expect(wrapper.vm.data).toBe(60)
expect(fetcher).toHaveBeenCalledTimes(0)

await vi.advanceTimersByTime(101)
wrapper.vm.refresh()
await runTimers()
expect(wrapper.vm.data).toBe(42)
expect(fetcher).toHaveBeenCalledTimes(1)
})
)

it('refreshes the data if mounted and the key changes', async () => {
const { wrapper, fetcher } = mountDynamicKey({
Expand Down

0 comments on commit 0b4c1fc

Please sign in to comment.