Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

usePrefetchQuery.test-d.tsx

36 lines886 Bytes

1import { describe, expectTypeOf, it } from 'vitest'
2import { usePrefetchQuery } from '..'
3​
4describe('usePrefetchQuery', () => {
5 it('should return nothing', () => {
6 const result = usePrefetchQuery({
7 queryKey: ['key'],
8 queryFn: () => Promise.resolve(5),
9 })
10​
11 expectTypeOf(result).toEqualTypeOf<void>()
12 })
13​
14 it('should not allow refetchInterval, enabled or throwOnError options', () => {
15 usePrefetchQuery({
16 queryKey: ['key'],
17 queryFn: () => Promise.resolve(5),
18 // @ts-expect-error TS2345
19 refetchInterval: 1000,
20 })
21​
22 usePrefetchQuery({
23 queryKey: ['key'],
24 queryFn: () => Promise.resolve(5),
25 // @ts-expect-error TS2345
26 enabled: true,
27 })
28​
29 usePrefetchQuery({
30 queryKey: ['key'],
31 queryFn: () => Promise.resolve(5),
32 // @ts-expect-error TS2345
33 throwOnError: true,
34 })
35 })
36})