Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useIsFetching.test-d.ts

18 lines645 Bytes

1import { describe, expectTypeOf, it } from 'vitest'
2import { useIsFetching } from '../../src/index.js'
3​
4describe('useIsFetching', () => {
5 it('should accept filters without fetchStatus', () => {
6 expectTypeOf(useIsFetching().current).toEqualTypeOf<number>()
7 expectTypeOf(
8 useIsFetching({ queryKey: ['key'], exact: true }).current,
9 ).toEqualTypeOf<number>()
10 })
11​
12 it('should reject a fetchStatus filter', () => {
13 expectTypeOf(
14 // @ts-expect-error useIsFetching always filters by fetchStatus: 'fetching'
15 useIsFetching({ queryKey: ['key'], fetchStatus: 'paused' }).current,
16 ).toEqualTypeOf<number>()
17 })
18})