Success.test.tsx20 lines · main
1import { screen } from '@testing-library/react'
2import userEvent from '@testing-library/user-event'
3import { describe, expect, it, vi } from 'vitest'
4
5import { Success } from './Success'
6import { customRender } from '@/tests/lib/custom-render'
7
8describe('Success', () => {
9 it('renders a local finish action when provided', async () => {
10 const onFinish = vi.fn()
11
12 customRender(<Success onFinish={onFinish} finishLabel="Done" />)
13
14 expect(screen.queryByRole('link', { name: 'Done' })).not.toBeInTheDocument()
15
16 await userEvent.click(screen.getByRole('button', { name: 'Done' }))
17
18 expect(onFinish).toHaveBeenCalledTimes(1)
19 })
20})