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