From 3ff4c37a7a2c40340c17f9e6c1754444bce0f839 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 31 Oct 2023 16:00:45 +0100 Subject: refactor(components): rewrite Modal component * add an optional close button * add an icon prop --- .../molecules/modals/tooltip/tooltip.test.tsx | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/components/molecules/modals/tooltip/tooltip.test.tsx (limited to 'src/components/molecules/modals/tooltip/tooltip.test.tsx') diff --git a/src/components/molecules/modals/tooltip/tooltip.test.tsx b/src/components/molecules/modals/tooltip/tooltip.test.tsx new file mode 100644 index 0000000..1596670 --- /dev/null +++ b/src/components/molecules/modals/tooltip/tooltip.test.tsx @@ -0,0 +1,42 @@ +import { describe, expect, it } from '@jest/globals'; +import { render, screen as rtlScreen } from '../../../../../tests/utils'; +import { Tooltip } from './tooltip'; + +const title = 'A custom title'; +const children = + 'Labore ullam delectus sit modi quam dolores. Ratione id sint aliquid facilis ipsum. Unde necessitatibus provident minus.'; + +describe('Tooltip', () => { + it('renders a title and a body', () => { + render({children}); + + expect(rtlScreen.getByText(title)).toBeInTheDocument(); + expect(rtlScreen.getByText(children)).toBeInTheDocument(); + }); + + it('can render a hidden modal', () => { + render( + + {children} + + ); + + // Neither toBeVisible or toHaveStyle are working. + //expect(rtlScreen.getByText(children)).not.toBeVisible(); + //expect(rtlScreen.getByText(children)).toHaveStyle({ visibility: 'hidden' }); + expect(rtlScreen.getByText(children)).toHaveClass('tooltip--hidden'); + }); + + it('can render a visible modal', () => { + render( + + {children} + + ); + + expect(rtlScreen.getByText(children)).toBeVisible(); + expect(rtlScreen.getByText(children)).toHaveStyle({ + visibility: 'visible', + }); + }); +}); -- cgit v1.2.3