diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-09 18:26:23 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 15522ec9146f6f1956620355c44dea2a6a75b67c (patch) | |
| tree | 7be0c4ca96cb3e59d2ee989785a6b6a286e6169d /src/components/atoms/figure/figure.test.tsx | |
| parent | 891441a76173c708c6604fa203b175aefa222333 (diff) | |
refactor(components): replace ResponsiveImage with Figure component
The styles applied to ResponsiveImage are related to the figure and
figcaption elements. Those elements could be use with other contents
than images. So I extracted them in a Figure component. The
ResponsiveImage component is no longer useful: the consumer should use
the Image component from `next` and wrap it in a link if needed.
Diffstat (limited to 'src/components/atoms/figure/figure.test.tsx')
| -rw-r--r-- | src/components/atoms/figure/figure.test.tsx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/components/atoms/figure/figure.test.tsx b/src/components/atoms/figure/figure.test.tsx new file mode 100644 index 0000000..90a07c7 --- /dev/null +++ b/src/components/atoms/figure/figure.test.tsx @@ -0,0 +1,32 @@ +import { describe, expect, it } from '@jest/globals'; +import { render, screen as rtlScreen } from '@testing-library/react'; +import { Figure } from './figure'; + +describe('Figure', () => { + it('renders the figure contents', () => { + const body = 'tempora et quis'; + + render(<Figure>{body}</Figure>); + + expect(rtlScreen.getByRole('figure')).toHaveTextContent(body); + }); + + it('can render its contents with a caption', () => { + const body = 'tempora et quis'; + const caption = 'velit dolores magnam'; + + render(<Figure caption={caption}>{body}</Figure>); + + expect(rtlScreen.getByRole('figure', { name: caption })).toHaveTextContent( + body + ); + }); + + it('can style the figure with borders', () => { + const body = 'tempora et quis'; + + render(<Figure hasBorders>{body}</Figure>); + + expect(rtlScreen.getByRole('figure')).toHaveClass('wrapper--has-borders'); + }); +}); |
