Files
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

34 lines
846 B
TypeScript

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { render } from '@testing-library/svelte'
import { QueryClient } from '@tanstack/query-core'
import Base from './Base.svelte'
describe('QueryClientProvider', () => {
let queryClient: QueryClient
beforeEach(() => {
vi.useFakeTimers()
queryClient = new QueryClient()
})
afterEach(() => {
queryClient.clear()
vi.useRealTimers()
})
it('should set a specific cache for all queries to use', async () => {
const queryCache = queryClient.getQueryCache()
const rendered = render(Base, {
props: {
queryClient,
},
})
await vi.advanceTimersByTimeAsync(10)
expect(rendered.getByText('Data: test')).toBeInTheDocument()
expect(queryCache.find({ queryKey: ['hello'] })?.state.data).toBe('test')
})
})