Skip to content

Commit e786913

Browse files
authored
test(solid-query): simplify type inference tests in useQueryOptions (#9080)
1 parent 8226d41 commit e786913

File tree

1 file changed

+34
-40
lines changed

1 file changed

+34
-40
lines changed

packages/solid-query/src/__tests__/useQueryOptions.test-d.tsx

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import type {
88
UndefinedInitialDataInfiniteOptions,
99
} from '../infiniteQueryOptions'
1010

11-
const doNotRun = (_callback: () => void) => {}
12-
1311
describe('infiniteQueryOptions', () => {
1412
it('should infer defined types', () => {
1513
const options = infiniteQueryOptions({
@@ -23,27 +21,25 @@ describe('infiniteQueryOptions', () => {
2321
initialPageParam: 0,
2422
})
2523

26-
doNotRun(() => {
27-
expectTypeOf(useInfiniteQuery(() => options).data).toEqualTypeOf<
28-
InfiniteData<{ wow: boolean }, unknown>
29-
>()
24+
expectTypeOf(useInfiniteQuery(() => options).data).toEqualTypeOf<
25+
InfiniteData<{ wow: boolean }, unknown>
26+
>()
3027

31-
expectTypeOf(options).toMatchTypeOf<
32-
ReturnType<
33-
DefinedInitialDataInfiniteOptions<
34-
{ wow: boolean },
35-
Error,
36-
InfiniteData<{ wow: boolean }, unknown>,
37-
Array<string>,
38-
number | undefined
39-
>
28+
expectTypeOf(options).toMatchTypeOf<
29+
ReturnType<
30+
DefinedInitialDataInfiniteOptions<
31+
{ wow: boolean },
32+
Error,
33+
InfiniteData<{ wow: boolean }, unknown>,
34+
Array<string>,
35+
number | undefined
4036
>
41-
>()
37+
>
38+
>()
4239

43-
expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf<
44-
InfiniteData<{ wow: boolean }>
45-
>()
46-
})
40+
expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf<
41+
InfiniteData<{ wow: boolean }>
42+
>()
4743
})
4844

4945
it('should work without defined types', () => {
@@ -54,28 +50,26 @@ describe('infiniteQueryOptions', () => {
5450
initialPageParam: 0,
5551
})
5652

57-
doNotRun(() => {
58-
expectTypeOf(() => useInfiniteQuery(() => options).data).toEqualTypeOf<
59-
() => InfiniteData<{ wow: boolean }, unknown> | undefined
60-
>()
53+
expectTypeOf(() => useInfiniteQuery(() => options).data).toEqualTypeOf<
54+
() => InfiniteData<{ wow: boolean }, unknown> | undefined
55+
>()
6156

62-
expectTypeOf(options).toMatchTypeOf<
63-
ReturnType<
64-
UndefinedInitialDataInfiniteOptions<
65-
{ wow: boolean },
66-
Error,
67-
InfiniteData<{ wow: boolean }, unknown>,
68-
Array<string>,
69-
number
70-
>
57+
expectTypeOf(options).toMatchTypeOf<
58+
ReturnType<
59+
UndefinedInitialDataInfiniteOptions<
60+
{ wow: boolean },
61+
Error,
62+
InfiniteData<{ wow: boolean }, unknown>,
63+
Array<string>,
64+
number
7165
>
72-
>()
66+
>
67+
>()
7368

74-
expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf<
75-
InfiniteData<{
76-
wow: boolean
77-
}>
78-
>()
79-
})
69+
expectTypeOf(options.queryKey[dataTagSymbol]).toEqualTypeOf<
70+
InfiniteData<{
71+
wow: boolean
72+
}>
73+
>()
8074
})
8175
})

0 commit comments

Comments
 (0)