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

mutation-options.test-d.ts

22 lines619 Bytes

1import { mutationOptions } from '../mutation-options'
2​
3describe('mutationOptions', () => {
4 test('should not allow excess properties', () => {
5 return mutationOptions({
6 mutationFn: () => Promise.resolve(5),
7 mutationKey: ['key'],
8 // @ts-expect-error this is a good error, because onMutates does not exist!
9 onMutates: 1000,
10 })
11 })
12​
13 test('should infer types for callbacks', () => {
14 return mutationOptions({
15 mutationFn: () => Promise.resolve(5),
16 mutationKey: ['key'],
17 onSuccess: (data) => {
18 expectTypeOf(data).toEqualTypeOf<number>()
19 },
20 })
21 })
22})