Skip to content

Commit

Permalink
add tests for create dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
aleckvincent committed Dec 9, 2024
1 parent 75f7918 commit 7d5d3ab
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen, fireEvent } from '../../../../../../test-utils.tsx'
import { describe, it, vi } from 'vitest'
import MissionCreateDialog from '../mission-create-dialog.tsx'

describe('MissionCreateDialog', () => {
it('renders the dialog when isOpen is true', () => {
render(<MissionCreateDialog isOpen={true} onClose={vi.fn()} />)
expect(screen.getByText("Création d'un rapport de mission")).toBeInTheDocument()
})

it('does not render the dialog when isOpen is false', () => {
render(<MissionCreateDialog isOpen={false} onClose={vi.fn()} />)
expect(screen.queryByText("Création d'un rapport de mission")).not.toBeInTheDocument()
})

it('calls onClose when the close button is clicked', () => {
const handleClose = vi.fn()
render(<MissionCreateDialog isOpen={true} onClose={handleClose} />)

fireEvent.click(screen.getByText('Annuler'))
expect(handleClose).toHaveBeenCalled()
})
})

0 comments on commit 7d5d3ab

Please sign in to comment.