From 3f73f8233df3d0d210c4a0e6f946013325ed3221 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 8 Sep 2025 21:44:06 +0900 Subject: [PATCH] test(svelte-query/createMutation): improve callback assertions with 'toHaveBeenNthCalledWith' and apply shorthand property syntax in FailureExample --- .../tests/createMutation/FailureExample.svelte | 2 +- .../tests/createMutation/createMutation.test.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/svelte-query/tests/createMutation/FailureExample.svelte b/packages/svelte-query/tests/createMutation/FailureExample.svelte index 9855664e8b..7d3292d526 100644 --- a/packages/svelte-query/tests/createMutation/FailureExample.svelte +++ b/packages/svelte-query/tests/createMutation/FailureExample.svelte @@ -12,7 +12,7 @@ const queryClient = new QueryClient() setQueryClientContext(queryClient) - const mutation = createMutation({ mutationFn: mutationFn }) + const mutation = createMutation({ mutationFn }) diff --git a/packages/svelte-query/tests/createMutation/createMutation.test.ts b/packages/svelte-query/tests/createMutation/createMutation.test.ts index 9cccd59ef5..6fd57ed063 100644 --- a/packages/svelte-query/tests/createMutation/createMutation.test.ts +++ b/packages/svelte-query/tests/createMutation/createMutation.test.ts @@ -48,16 +48,14 @@ describe('createMutation', () => { expect(rendered.queryByText('Count: 3')).toBeInTheDocument() expect(onSuccessMock).toHaveBeenCalledTimes(3) - - expect(onSuccessMock).toHaveBeenCalledWith(1) - expect(onSuccessMock).toHaveBeenCalledWith(2) - expect(onSuccessMock).toHaveBeenCalledWith(3) + expect(onSuccessMock).toHaveBeenNthCalledWith(1, 1) + expect(onSuccessMock).toHaveBeenNthCalledWith(2, 2) + expect(onSuccessMock).toHaveBeenNthCalledWith(3, 3) expect(onSettledMock).toHaveBeenCalledTimes(3) - - expect(onSettledMock).toHaveBeenCalledWith(1) - expect(onSettledMock).toHaveBeenCalledWith(2) - expect(onSettledMock).toHaveBeenCalledWith(3) + expect(onSettledMock).toHaveBeenNthCalledWith(1, 1) + expect(onSettledMock).toHaveBeenNthCalledWith(2, 2) + expect(onSettledMock).toHaveBeenNthCalledWith(3, 3) }) test('Set correct values for `failureReason` and `failureCount` on multiple mutate calls', async () => {