import { type InfiniteData, type UseSuspenseInfiniteQueryResult, infiniteQueryOptions } from '@tanstack/react-query'
import type { ReactNode } from 'react'
import { describe, expectTypeOf, it } from 'vitest'
import { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery'
import { queryFn, queryKey } from './test-utils'
describe('', () => {
it('type check', () => {
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => (
<>
{query.data.pages
.filter(({ text }) => text)
.map((item, index) => (
{item.text}
))}
>
)}
))()
;(() => (
{(query) => {
expectTypeOf(query).toEqualTypeOf>()
expectTypeOf(query.data).toEqualTypeOf>()
expectTypeOf(query.status).toEqualTypeOf<'success' | 'error'>()
return <>>
}}
))()
;(() => (
({
pages: data.pages.map(({ text }) => text),
pageParams: data.pageParams,
})}
>
{(selectedQuery) => {
expectTypeOf(selectedQuery).toEqualTypeOf>()
expectTypeOf(selectedQuery.data).toEqualTypeOf>()
expectTypeOf(selectedQuery.status).toEqualTypeOf<'success' | 'error'>()
return <>>
}}
))()
const options = infiniteQueryOptions({ queryKey, queryFn })
;(() => (
{(query) => {
expectTypeOf(query).toEqualTypeOf>()
expectTypeOf(query.data).toEqualTypeOf>()
expectTypeOf(query.status).toEqualTypeOf<'success' | 'error'>()
return <>>
}}
))()
;(() => (
({
pages: data.pages.map(({ text }) => text),
pageParams: data.pageParams,
})}
>
{(selectedQuery) => {
expectTypeOf(selectedQuery).toEqualTypeOf>()
expectTypeOf(selectedQuery.data).toEqualTypeOf>()
expectTypeOf(selectedQuery.status).toEqualTypeOf<'success' | 'error'>()
return <>>
}}
))()
expectTypeOf(
{() => <>>}
).toEqualTypeOf()
expectTypeOf(
{() => <>>}
).not.toEqualTypeOf()
expectTypeOf(
{() => <>>}
).toEqualTypeOf()
expectTypeOf(
{() => <>>}
).not.toEqualTypeOf()
})
})