Skip to content

Commit 7d3b86c

Browse files
authored
test(vue-query/mutationOptions): add identity tests for getter overloads (TanStack#10468)
1 parent 6384368 commit 7d3b86c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/vue-query/src/__tests__/mutationOptions.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ describe('mutationOptions', () => {
3535
expect(mutationOptions(object)).toStrictEqual(object)
3636
})
3737

38+
it('should return the getter received as a parameter without any modification (with mutationKey in mutationOptions)', () => {
39+
const getter = () =>
40+
({
41+
mutationKey: ['key'],
42+
mutationFn: () => sleep(10).then(() => 5),
43+
}) as const
44+
45+
expect(mutationOptions(getter)).toBe(getter)
46+
})
47+
48+
it('should return the getter received as a parameter without any modification (without mutationKey in mutationOptions)', () => {
49+
const getter = () =>
50+
({
51+
mutationFn: () => sleep(10).then(() => 5),
52+
}) as const
53+
54+
expect(mutationOptions(getter)).toBe(getter)
55+
})
56+
3857
it('should return the number of fetching mutations when used with useIsMutating (with mutationKey in mutationOptions)', async () => {
3958
const isMutatingArray: Array<number> = []
4059
const mutationOpts = mutationOptions({

0 commit comments

Comments
 (0)