From 90334f33f1cb3bb9b1cb637e7faef93be6bee746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myl=C3=A8ne?= <187286904+mleroy-pass@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:37:18 +0100 Subject: [PATCH] (PC-33528)[PRO] feat: add test to the new component --- .../ui-kit/MultiSelect/MultiSelect.spec.tsx | 29 ---- .../MultiSelect/MultiSelect.stories.tsx | 11 ++ pro/src/ui-kit/MultiSelect/MultiSelect.tsx | 10 +- pro/src/ui-kit/MultiSelect/TODO.md | 1 + .../__specs__/MultiSelect.spec.tsx | 132 ++++++++++++++++++ .../__specs__/MultiSelectPanel.spec.tsx | 99 +++++++++++++ 6 files changed, 246 insertions(+), 36 deletions(-) delete mode 100644 pro/src/ui-kit/MultiSelect/MultiSelect.spec.tsx create mode 100644 pro/src/ui-kit/MultiSelect/__specs__/MultiSelect.spec.tsx create mode 100644 pro/src/ui-kit/MultiSelect/__specs__/MultiSelectPanel.spec.tsx diff --git a/pro/src/ui-kit/MultiSelect/MultiSelect.spec.tsx b/pro/src/ui-kit/MultiSelect/MultiSelect.spec.tsx deleted file mode 100644 index ffc4c57bf9c..00000000000 --- a/pro/src/ui-kit/MultiSelect/MultiSelect.spec.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { screen } from '@testing-library/react' -import { axe } from 'vitest-axe' - -import { - renderWithProviders, - RenderWithProvidersOptions, -} from 'commons/utils/renderWithProviders' - -import { MultiSelect } from './MultiSelect' - -const renderMultiSelect = (options?: RenderWithProvidersOptions) => { - return renderWithProviders(, { ...options }) -} - -describe('', () => { - it('should render correctly', async () => { - renderMultiSelect() - - expect( - await screen.findByRole('heading', { name: /MultiSelect/ }) - ).toBeInTheDocument() - }) - - it('should not have accessibility violations', async () => { - const { container } = renderMultiSelect() - - expect(await axe(container)).toHaveNoViolations() - }) -}) diff --git a/pro/src/ui-kit/MultiSelect/MultiSelect.stories.tsx b/pro/src/ui-kit/MultiSelect/MultiSelect.stories.tsx index 0040eefe920..2dcd9948586 100644 --- a/pro/src/ui-kit/MultiSelect/MultiSelect.stories.tsx +++ b/pro/src/ui-kit/MultiSelect/MultiSelect.stories.tsx @@ -57,3 +57,14 @@ export const WithSearchInput: StoryObj = { label: 'Selectionner des départements', }, } + +export const WithSelectAllOption: StoryObj = { + args: { + ...defaultProps, + hasSelectAllOptions: true, + searchExample: 'Ex : 44 - Nantes', + searchLabel: 'Rechercher des départements', + legend: 'Départements', + label: 'Selectionner des départements', + }, +} diff --git a/pro/src/ui-kit/MultiSelect/MultiSelect.tsx b/pro/src/ui-kit/MultiSelect/MultiSelect.tsx index 331178b987b..a6ee2e80ef9 100644 --- a/pro/src/ui-kit/MultiSelect/MultiSelect.tsx +++ b/pro/src/ui-kit/MultiSelect/MultiSelect.tsx @@ -124,7 +124,7 @@ export const MultiSelect = ({ )} item.id)} removeOption={handleRemoveItem} fieldName="tags" @@ -137,8 +137,7 @@ export const MultiSelect = ({ ) } -{ - /*
+/*
@@ -169,10 +168,8 @@ export const MultiSelect = ({
Pervenche
*/ -} -{ - /*
+/*
{departments.map(department => (