Open History to see the last commit
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})