Skip to content

Commit 09971c0

Browse files
authored
test(angular-query/injectMutation): add test for 'throwOnError' with 'mutate' (#10219)
1 parent 6fc3b45 commit 09971c0

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,28 @@ describe('injectMutation', () => {
412412
expect(boundaryFn).toHaveBeenCalledTimes(1)
413413
expect(boundaryFn).toHaveBeenCalledWith(err)
414414
})
415+
416+
test('should throw when throwOnError is true and mutate is used', async () => {
417+
const { mutate } = TestBed.runInInjectionContext(() => {
418+
return injectMutation(() => ({
419+
mutationKey: ['fake'],
420+
mutationFn: () => {
421+
return Promise.reject(
422+
new Error('Expected mock error. All is well!'),
423+
)
424+
},
425+
throwOnError: true,
426+
}))
427+
})
428+
429+
TestBed.tick()
430+
431+
mutate()
432+
433+
await expect(vi.advanceTimersByTimeAsync(0)).rejects.toThrow(
434+
'Expected mock error. All is well!',
435+
)
436+
})
415437
})
416438

417439
test('should throw when throwOnError is true', async () => {

0 commit comments

Comments
 (0)