Skip to content

Commit 4c489e4

Browse files
authored
test(vue-query/mutationOptions): add shallow ref test for getter overload (#10473)
1 parent c8de088 commit 4c489e4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,4 +700,20 @@ describe('mutationOptions', () => {
700700
expect(data.value).toEqual({ nested: { count: 0 } })
701701
expect(isReactive(data.value?.nested)).toBe(false)
702702
})
703+
704+
it('should return data in a shallow ref when shallow is true (getter)', async () => {
705+
const mutationOpts = mutationOptions(() => ({
706+
mutationKey: ['key'],
707+
mutationFn: () => sleep(10).then(() => ({ nested: { count: 0 } })),
708+
shallow: true,
709+
}))
710+
711+
const { mutate, data } = useMutation(mutationOpts)
712+
713+
mutate()
714+
await vi.advanceTimersByTimeAsync(10)
715+
716+
expect(data.value).toEqual({ nested: { count: 0 } })
717+
expect(isReactive(data.value?.nested)).toBe(false)
718+
})
703719
})

0 commit comments

Comments
 (0)