Skip to content

Commit ccedf33

Browse files
authored
test(svelte-query/createMutation): improve callback assertions with 'toHaveBeenNthCalledWith' and apply shorthand property syntax in FailureExample (#9630)
1 parent 2bf8fa3 commit ccedf33

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/svelte-query/tests/createMutation/FailureExample.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const queryClient = new QueryClient()
1313
setQueryClientContext(queryClient)
1414
15-
const mutation = createMutation({ mutationFn: mutationFn })
15+
const mutation = createMutation({ mutationFn })
1616
</script>
1717

1818
<button on:click={() => $mutation.mutate({ count: ++$count })}>Mutate</button>

packages/svelte-query/tests/createMutation/createMutation.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ describe('createMutation', () => {
4848
expect(rendered.queryByText('Count: 3')).toBeInTheDocument()
4949

5050
expect(onSuccessMock).toHaveBeenCalledTimes(3)
51-
52-
expect(onSuccessMock).toHaveBeenCalledWith(1)
53-
expect(onSuccessMock).toHaveBeenCalledWith(2)
54-
expect(onSuccessMock).toHaveBeenCalledWith(3)
51+
expect(onSuccessMock).toHaveBeenNthCalledWith(1, 1)
52+
expect(onSuccessMock).toHaveBeenNthCalledWith(2, 2)
53+
expect(onSuccessMock).toHaveBeenNthCalledWith(3, 3)
5554

5655
expect(onSettledMock).toHaveBeenCalledTimes(3)
57-
58-
expect(onSettledMock).toHaveBeenCalledWith(1)
59-
expect(onSettledMock).toHaveBeenCalledWith(2)
60-
expect(onSettledMock).toHaveBeenCalledWith(3)
56+
expect(onSettledMock).toHaveBeenNthCalledWith(1, 1)
57+
expect(onSettledMock).toHaveBeenNthCalledWith(2, 2)
58+
expect(onSettledMock).toHaveBeenNthCalledWith(3, 3)
6159
})
6260

6361
test('Set correct values for `failureReason` and `failureCount` on multiple mutate calls', async () => {

0 commit comments

Comments
 (0)