Skip to content

Commit

Permalink
test(react-query): update vitest type test correctly (#6990)
Browse files Browse the repository at this point in the history
* test(react-query): update vitest type test code correctly (expectTypeOf)

* chore: update

* chore(react-query): remove optional chaining

* chore: update

* chore: update
  • Loading branch information
manudeli committed Mar 9, 2024
1 parent 4e340a2 commit f9ecde2
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 141 deletions.
14 changes: 4 additions & 10 deletions packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx
@@ -1,9 +1,9 @@
import { describe, expectTypeOf, it } from 'vitest'
import { QueryClient } from '@tanstack/query-core'
import { type InfiniteData, dataTagSymbol } from '@tanstack/query-core'
import { infiniteQueryOptions } from '../infiniteQueryOptions'
import { useInfiniteQuery } from '../useInfiniteQuery'
import { useSuspenseInfiniteQuery } from '../useSuspenseInfiniteQuery'
import type { InfiniteData, dataTagSymbol } from '@tanstack/query-core'

describe('queryOptions', () => {
it('should not allow excess properties', () => {
Expand Down Expand Up @@ -75,9 +75,7 @@ describe('queryOptions', () => {
initialPageParam: 1,
})

expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf<
InfiniteData<string>
>()
expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf<InfiniteData<string>>()
})
it('should tag the queryKey even if no promise is returned', () => {
const { queryKey } = infiniteQueryOptions({
Expand All @@ -87,9 +85,7 @@ describe('queryOptions', () => {
initialPageParam: 1,
})

expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf<
InfiniteData<string>
>()
expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf<InfiniteData<string>>()
})
it('should tag the queryKey with the result type of the QueryFn if select is used', () => {
const { queryKey } = infiniteQueryOptions({
Expand All @@ -100,9 +96,7 @@ describe('queryOptions', () => {
initialPageParam: 1,
})

expectTypeOf<(typeof queryKey)[typeof dataTagSymbol]>().toEqualTypeOf<
InfiniteData<string>
>()
expectTypeOf(queryKey[dataTagSymbol]).toEqualTypeOf<InfiniteData<string>>()
})
it('should return the proper type when passed to getQueryData', () => {
const { queryKey } = infiniteQueryOptions({
Expand Down

0 comments on commit f9ecde2

Please sign in to comment.