Skip to content

Commit c47c671

Browse files
authored
test(svelte-query/useMutationState): add type tests for default 'MutationState' and 'select' inference (#10504)
1 parent da62c8a commit c47c671

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { describe, expectTypeOf, it } from 'vitest'
2+
import { useMutationState } from '../../src/index.js'
3+
import type { MutationState, MutationStatus } from '@tanstack/query-core'
4+
5+
describe('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+
})

0 commit comments

Comments
 (0)