-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathusePrefetchQueries.test-d.tsx
68 lines (63 loc) · 1.47 KB
/
usePrefetchQueries.test-d.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { describe, expectTypeOf, it } from 'vitest'
import { usePrefetchQueries } from '..'
describe('usePrefetchQueries', () => {
it('should return nothing', () => {
const result = usePrefetchQueries({
queries: [
{
queryKey: ['key1'],
queryFn: () => Promise.resolve(5),
},
{
queryKey: ['key2'],
queryFn: () => Promise.resolve('data'),
},
{
queryKey: ['key3'],
queryFn: () =>
Promise.resolve({
foo: 1,
bar: 'fizzbuzz',
}),
},
],
})
expectTypeOf(result).toEqualTypeOf<void>()
})
it('should not allow refetchInterval, enabled or throwOnError options', () => {
usePrefetchQueries({
queries: [
{
queryKey: ['key1'],
queryFn: () => Promise.resolve(5),
// @ts-expect-error TS2345
refetchInterval: 1000,
},
],
})
usePrefetchQueries({
queries: [
{
queryKey: ['key1'],
queryFn: () => Promise.resolve('data'),
// @ts-expect-error TS2345
enabled: true,
},
],
})
usePrefetchQueries({
queries: [
{
queryKey: ['key1'],
queryFn: () =>
Promise.resolve({
foo: 1,
bar: 'fizzbuzz',
}),
// @ts-expect-error TS2345
throwOnError: true,
},
],
})
})
})