Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

createMutation.test.ts

23 lines570 Bytes

1import { describe, expect, it, vi } from 'vitest'
2import { fireEvent, render, waitFor } from '@testing-library/svelte'
3import CreateMutation from './CreateMutation.svelte'
4​
5describe('createMutation', () => {
6 it('Call mutate and check function runs', async () => {
7 const mutationFn = vi.fn()
8​
9 const rendered = render(CreateMutation, {
10 props: {
11 options: {
12 mutationFn,
13 },
14 },
15 })
16​
17 fireEvent.click(rendered.getByRole('button'))
18​
19 await waitFor(() => {
20 expect(mutationFn).toHaveBeenCalledTimes(1)
21 })
22 })
23})