File size: 684 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { describe, expectTypeOf, it } from 'vitest'
import { useMutationState } from '../useMutationState'
import type { MutationState, MutationStatus } from '@tanstack/query-core'
describe('useMutationState', () => {
it('should default to QueryState', () => {
const result = useMutationState(() => ({
filters: { status: 'pending' },
}))
expectTypeOf(result()).toEqualTypeOf<Array<MutationState>>()
})
it('should infer with select', () => {
const result = useMutationState(() => ({
filters: { status: 'pending' },
select: (mutation) => mutation.state.status,
}))
expectTypeOf(result()).toEqualTypeOf<Array<MutationStatus>>()
})
})
|