snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
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

This commit is contained in:
upstream-mirror
2026-09-16 01:13:08 +05:00
commit 3a013ccdfe
3570 changed files with 490194 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
<script lang="ts">
import { QueryClientProvider } from '../../src/index.js'
import Child from './Child.svelte'
import type { QueryClient } from '@tanstack/query-core'
type Props = {
queryClient: QueryClient
}
let { queryClient }: Props = $props()
</script>
<QueryClientProvider client={queryClient}>
<Child />
</QueryClientProvider>

View File

@@ -0,0 +1,11 @@
<script lang="ts">
import { createQuery } from '../../src/index.js'
import { sleep } from '@tanstack/query-test-utils'
const query = createQuery(() => ({
queryKey: ['hello'],
queryFn: () => sleep(10).then(() => 'test'),
}))
</script>
<div>Data: {query.data ?? 'undefined'}</div>

View File

@@ -0,0 +1,33 @@
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')
})
})