Success.test.tsx 648 B

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