From 7d5d3abbfb89dbfcd9b6bc019dba5f1e7089984c Mon Sep 17 00:00:00 2001 From: aleckvincent Date: Mon, 9 Dec 2024 12:14:09 +0100 Subject: [PATCH] add tests for create dialog --- .../__tests__/mission-create-dialog.test.tsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 frontend/src/v2/features/ulam/components/element/__tests__/mission-create-dialog.test.tsx diff --git a/frontend/src/v2/features/ulam/components/element/__tests__/mission-create-dialog.test.tsx b/frontend/src/v2/features/ulam/components/element/__tests__/mission-create-dialog.test.tsx new file mode 100644 index 00000000..fdc566d3 --- /dev/null +++ b/frontend/src/v2/features/ulam/components/element/__tests__/mission-create-dialog.test.tsx @@ -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() + expect(screen.getByText("Création d'un rapport de mission")).toBeInTheDocument() + }) + + it('does not render the dialog when isOpen is false', () => { + render() + 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() + + fireEvent.click(screen.getByText('Annuler')) + expect(handleClose).toHaveBeenCalled() + }) +})