Open History to see the last commit
1import { assertType, describe, expectTypeOf, it } from 'vitest'
2import { usePrefetchInfiniteQuery } from '..'
3β
4describe('usePrefetchInfiniteQuery', () => {
5 it('should return nothing', () => {
6 const result = usePrefetchInfiniteQuery({
7 queryKey: ['key'],
8 queryFn: () => Promise.resolve(5),
9 initialPageParam: 1,
10 getNextPageParam: () => 1,
11 })
12β
13 expectTypeOf(result).toEqualTypeOf<void>()
14 })
15β
16 it('should require initialPageParam and getNextPageParam', () => {
17 assertType(
18 // @ts-expect-error TS2345
19 usePrefetchInfiniteQuery({
20 queryKey: ['key'],
21 queryFn: () => Promise.resolve(5),
22 }),
23 )
24 })
25β
26 it('should not allow refetchInterval, enabled or throwOnError options', () => {
27 assertType(
28 usePrefetchInfiniteQuery({
29 queryKey: ['key'],
30 queryFn: () => Promise.resolve(5),
31 initialPageParam: 1,
32 getNextPageParam: () => 1,
33 // @ts-expect-error TS2353
34 refetchInterval: 1000,
35 }),
36 )
37β
38 assertType(
39 usePrefetchInfiniteQuery({
40 queryKey: ['key'],
41 queryFn: () => Promise.resolve(5),
42 initialPageParam: 1,
43 getNextPageParam: () => 1,
44 // @ts-expect-error TS2353
45 enabled: true,
46 }),
47 )
48β
49 assertType(
50 usePrefetchInfiniteQuery({
51 queryKey: ['key'],
52 queryFn: () => Promise.resolve(5),
53 initialPageParam: 1,
54 getNextPageParam: () => 1,
55 // @ts-expect-error TS2353
56 throwOnError: true,
57 }),
58 )
59 })
60})