Skip to content

Commit a330906

Browse files
committed
test(vue-query/mutationOptions): add runtime test for getter without 'mutationKey'
1 parent 9876ff7 commit a330906

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,19 @@ describe('mutationOptions', () => {
380380
expect(states.value).toEqual(['foo'])
381381
})
382382

383+
it('should work with getter passed to mutationOptions without mutationKey', async () => {
384+
const mutationOpts = mutationOptions(() => ({
385+
mutationFn: () => sleep(10).then(() => 'data'),
386+
}))
387+
388+
const { mutate, data } = useMutation(mutationOpts)
389+
390+
mutate()
391+
await vi.advanceTimersByTimeAsync(10)
392+
393+
expect(data.value).toEqual('data')
394+
})
395+
383396
it('should return data in a shallow ref when shallow is true', async () => {
384397
const mutationOpts = mutationOptions({
385398
mutationKey: ['key'],

0 commit comments

Comments
 (0)