@@ -4,56 +4,56 @@ import { queryOptions, useQuery } from '../index'
44describe ( 'useQuery' , ( ) => {
55 describe ( 'initialData' , ( ) => {
66 describe ( 'Config object overload' , ( ) => {
7- it ( 'TData should always be defined when initialData is provided as an object' , ( ) => {
8- const { data } = useQuery ( ( ) => ( {
9- queryKey : [ 'key' ] ,
10- queryFn : ( ) => ( { wow : true } ) ,
11- initialData : { wow : true } ,
12- } ) )
13-
14- expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
15- } )
7+ it ( 'TData should always be defined when initialData is provided as an object' , ( ) => {
8+ const { data } = useQuery ( ( ) => ( {
9+ queryKey : [ 'key' ] ,
10+ queryFn : ( ) => ( { wow : true } ) ,
11+ initialData : { wow : true } ,
12+ } ) )
1613
17- it ( 'TData should be defined when passed through queryOptions' , ( ) => {
18- const options = queryOptions ( {
19- queryKey : [ 'key' ] ,
20- queryFn : ( ) => ( { wow : true } ) ,
21- initialData : { wow : true } ,
14+ expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
2215 } )
23- const { data } = useQuery ( ( ) => options )
2416
25- expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
26- } )
17+ it ( 'TData should be defined when passed through queryOptions' , ( ) => {
18+ const options = queryOptions ( {
19+ queryKey : [ 'key' ] ,
20+ queryFn : ( ) => ( { wow : true } ) ,
21+ initialData : { wow : true } ,
22+ } )
23+ const { data } = useQuery ( ( ) => options )
2724
28- it ( 'TData should always be defined when initialData is provided as a function which ALWAYS returns the data' , ( ) => {
29- const { data } = useQuery ( ( ) => ( {
30- queryKey : [ 'key' ] ,
31- queryFn : ( ) => ( { wow : true } ) ,
32- initialData : ( ) => ( { wow : true } ) ,
33- } ) )
25+ expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
26+ } )
3427
35- expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
36- } )
28+ it ( 'TData should always be defined when initialData is provided as a function which ALWAYS returns the data' , ( ) => {
29+ const { data } = useQuery ( ( ) => ( {
30+ queryKey : [ 'key' ] ,
31+ queryFn : ( ) => ( { wow : true } ) ,
32+ initialData : ( ) => ( { wow : true } ) ,
33+ } ) )
3734
38- it ( 'TData should have undefined in the union when initialData is NOT provided' , ( ) => {
39- const { data } = useQuery ( ( ) => ( {
40- queryKey : [ 'key' ] ,
41- queryFn : ( ) => ( { wow : true } ) ,
42- } ) )
35+ expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } > ( )
36+ } )
4337
44- expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } | undefined > ( )
45- } )
38+ it ( 'TData should have undefined in the union when initialData is NOT provided' , ( ) => {
39+ const { data } = useQuery ( ( ) => ( {
40+ queryKey : [ 'key' ] ,
41+ queryFn : ( ) => ( { wow : true } ) ,
42+ } ) )
43+
44+ expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } | undefined > ( )
45+ } )
4646
47- it ( 'TData should have undefined in the union when initialData is provided as a function which can return undefined' , ( ) => {
48- const { data } = useQuery ( ( ) => ( {
49- queryKey : [ 'key' ] ,
50- queryFn : ( ) => ( { wow : true } ) ,
51- initialData : ( ) => undefined as { wow : boolean } | undefined ,
52- } ) )
47+ it ( 'TData should have undefined in the union when initialData is provided as a function which can return undefined' , ( ) => {
48+ const { data } = useQuery ( ( ) => ( {
49+ queryKey : [ 'key' ] ,
50+ queryFn : ( ) => ( { wow : true } ) ,
51+ initialData : ( ) => undefined as { wow : boolean } | undefined ,
52+ } ) )
5353
54- expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } | undefined > ( )
54+ expectTypeOf ( data ) . toEqualTypeOf < { wow : boolean } | undefined > ( )
55+ } )
5556 } )
56- } )
5757
5858 describe ( 'Query key overload' , ( ) => {
5959 it ( 'TData should always be defined when initialData is provided' , ( ) => {
0 commit comments