11import { describe , expectTypeOf , it } from 'vitest'
2- import { dataTagSymbol } from '@tanstack/query-core'
2+ import { QueryClient , dataTagSymbol } from '@tanstack/query-core'
33import { queryKey } from '@tanstack/query-test-utils'
44import { useInfiniteQuery } from '../useInfiniteQuery'
55import { infiniteQueryOptions } from '../infiniteQueryOptions'
@@ -10,6 +10,33 @@ import type {
1010} from '../infiniteQueryOptions'
1111
1212describe ( 'infiniteQueryOptions' , ( ) => {
13+ it ( 'should work when passed to infiniteQuery' , async ( ) => {
14+ const options = infiniteQueryOptions ( {
15+ getNextPageParam : ( ) => 10 ,
16+ queryKey : [ 'key' ] ,
17+ queryFn : ( ) => ( { wow : true } ) ,
18+ initialPageParam : 0 ,
19+ } )
20+
21+ const data = await new QueryClient ( ) . infiniteQuery ( options )
22+
23+ expectTypeOf ( data ) . toEqualTypeOf < InfiniteData < { wow : boolean } , number > > ( )
24+ } )
25+
26+ it ( 'should work when passed to infiniteQuery with select' , async ( ) => {
27+ const options = infiniteQueryOptions ( {
28+ getNextPageParam : ( ) => 10 ,
29+ queryKey : [ 'key' ] ,
30+ queryFn : ( ) => ( { wow : true } ) ,
31+ initialPageParam : 0 ,
32+ select : ( data ) => data . pages ,
33+ } )
34+
35+ const data = await new QueryClient ( ) . infiniteQuery ( options )
36+
37+ expectTypeOf ( data ) . toEqualTypeOf < Array < { wow : boolean } > > ( )
38+ } )
39+
1340 it ( 'should infer defined types' , ( ) => {
1441 const options = infiniteQueryOptions ( {
1542 getNextPageParam : ( ) => 10 ,
0 commit comments