Open History to see the last commit
1import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
2import { render } from '@testing-library/svelte'
3import { QueryCache } from '@tanstack/query-core'
4import ParentComponent from './ParentComponent.svelte'
5β
6describe('QueryClientProvider', () => {
7 beforeEach(() => {
8 vi.useFakeTimers()
9 })
10β
11 afterEach(() => {
12 vi.useRealTimers()
13 })
14β
15 test('Sets a specific cache for all queries to use', async () => {
16 const queryCache = new QueryCache()
17β
18 const rendered = render(ParentComponent, {
19 props: {
20 queryCache: queryCache,
21 },
22 })
23β
24 await vi.advanceTimersByTimeAsync(6)
25 expect(rendered.getByText('Data: test')).toBeInTheDocument()
26β
27 expect(queryCache.find({ queryKey: ['hello'] })).toBeDefined()
28 })
29})