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

createMutation.test.ts

24 lines568 Bytes

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