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