-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathmutation-options.test-d.ts
More file actions
33 lines (31 loc) · 989 Bytes
/
Copy pathmutation-options.test-d.ts
File metadata and controls
33 lines (31 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { assertType, describe, expectTypeOf, test } from 'vitest'
import { mutationOptions } from '../mutation-options'
describe('mutationOptions', () => {
test('should not allow excess properties', () => {
assertType<Parameters<typeof mutationOptions>>([
{
mutationFn: () => Promise.resolve(5),
mutationKey: ['key'],
// @ts-expect-error this is a good error, because onMutates does not exist!
onMutates: 1000,
},
])
assertType<Parameters<typeof mutationOptions>>([
{
mutationFn: () => Promise.resolve(5),
mutationKey: ['key'],
// @ts-expect-error this is a good error, because onMutates does not exist!
onMutates: 1000,
},
])
})
test('should infer types for callbacks', () => {
mutationOptions({
mutationFn: () => Promise.resolve(5),
mutationKey: ['key'],
onSuccess: (data) => {
expectTypeOf(data).toEqualTypeOf<number>()
},
})
})
})