forked from TanStack/query
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateQueries.test-d.tsx
More file actions
32 lines (29 loc) · 943 Bytes
/
createQueries.test-d.tsx
File metadata and controls
32 lines (29 loc) · 943 Bytes
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
import { describe, expectTypeOf, it } from 'vitest'
import { queryKey } from '@tanstack/query-test-utils'
import { queryOptions, useQueries } from '..'
import type { UseQueryResult } from '..'
describe('useQueries', () => {
it('should return correct data for dynamic queries with mixed result types', () => {
const Queries1 = {
get: () =>
queryOptions({
queryKey: queryKey(),
queryFn: () => Promise.resolve(1),
}),
}
const Queries2 = {
get: () =>
queryOptions({
queryKey: queryKey(),
queryFn: () => Promise.resolve(true),
}),
}
const queries1List = [1, 2, 3].map(() => ({ ...Queries1.get() }))
const result = useQueries(() => ({
queries: [...queries1List, { ...Queries2.get() }],
}))
expectTypeOf(result).toEqualTypeOf<
[...Array<UseQueryResult<number, Error>>, UseQueryResult<boolean, Error>]
>()
})
})