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