Skip to content
Source
Sign inSign up
TanStack/query

test(svelte-query/createMutation): improve callback assertions with 'toHaveBeenNthCalledWith' and apply shorthand property syntax in FailureExample #9630

Mergedsukvvon(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/9630/headmerged by TkDodo View on GitHub

Showing 2 changed files with 7 additions and 9 deletions.

x
0 of 2 viewed, 2 left
1 addition and 1 deletionpackages/svelte-query/tests/createMutation/FailureExample.svelteModified
View file
@@ -12,7 +12,7 @@
const queryClient = new QueryClient()
setQueryClientContext(queryClient)
​
- const mutation = createMutation({ mutationFn: mutationFn })
+ const mutation = createMutation({ mutationFn })
</script>
​
<button on:click={() => $mutation.mutate({ count: ++$count })}>Mutate</button>
6 additions and 8 deletionspackages/svelte-query/tests/createMutation/createMutation.test.tsModified
View file
@@ -48,16 +48,14 @@
expect(rendered.queryByText('Count: 3')).toBeInTheDocument()
​
expect(onSuccessMock).toHaveBeenCalledTimes(3)
+ expect(onSuccessMock).toHaveBeenNthCalledWith(1, 1)
+ expect(onSuccessMock).toHaveBeenNthCalledWith(2, 2)
+ expect(onSuccessMock).toHaveBeenNthCalledWith(3, 3)
​
- expect(onSuccessMock).toHaveBeenCalledWith(1)
- expect(onSuccessMock).toHaveBeenCalledWith(2)
- expect(onSuccessMock).toHaveBeenCalledWith(3)