@amsterdam/design-system-react 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Avatar/Avatar.d.ts +2 -2
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/CardHeading.d.ts +1 -1
- package/dist/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Column/Column.d.ts +1 -1
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/FieldSet/FieldSet.d.ts +11 -0
- package/dist/FieldSet/FieldSet.js +3 -3
- package/dist/Grid/Grid.d.ts +1 -1
- package/dist/Grid/GridCell.d.ts +1 -1
- package/dist/Hint/Hint.d.ts +1 -0
- package/dist/Hint/Hint.js +2 -2
- package/dist/Image/Image.js +1 -1
- package/dist/Label/Label.d.ts +11 -0
- package/dist/Label/Label.js +2 -2
- package/dist/LinkList/LinkList.d.ts +1 -1
- package/dist/Logo/Logo.d.ts +10 -5
- package/dist/Logo/Logo.js +17 -9
- package/dist/Menu/MenuLink.d.ts +2 -2
- package/dist/Page/Page.d.ts +6 -2
- package/dist/Page/Page.js +1 -1
- package/dist/PageFooter/PageFooter.d.ts +4 -1
- package/dist/PageFooter/PageFooterMenu.d.ts +27 -2
- package/dist/PageFooter/PageFooterMenu.js +6 -2
- package/dist/PageHeader/PageHeader.d.ts +14 -4
- package/dist/PageHeader/PageHeader.js +3 -2
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +2 -1
- package/dist/PageHeader/PageHeaderMenuIcon.js +1 -1
- package/dist/PageHeader/PageHeaderMenuLink.d.ts +7 -0
- package/dist/PageHeader/PageHeaderMenuLink.js +3 -2
- package/dist/Paragraph/Paragraph.d.ts +2 -2
- package/dist/Paragraph/Paragraph.js +8 -1
- package/dist/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/Radio/Radio.d.ts +1 -1
- package/dist/Row/Row.d.ts +1 -1
- package/dist/SearchField/SearchField.d.ts +1 -1
- package/dist/Spotlight/Spotlight.d.ts +1 -1
- package/dist/TimeInput/TimeInput.d.ts +1 -1
- package/dist/common/useIsAfterBreakpoint.d.ts +4 -4
- package/dist/common/useIsAfterBreakpoint.js +12 -13
- package/dist/index.cjs.js +95 -62
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1958 -61
- package/dist/index.esm.js +96 -63
- package/dist/index.esm.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +11 -16
- package/dist/Accordion/Accordion.test.d.ts +0 -5
- package/dist/Accordion/Accordion.test.js +0 -44
- package/dist/Accordion/AccordionSection.test.d.ts +0 -5
- package/dist/Accordion/AccordionSection.test.js +0 -100
- package/dist/ActionGroup/ActionGroup.test.d.ts +0 -5
- package/dist/ActionGroup/ActionGroup.test.js +0 -33
- package/dist/Alert/Alert.test.d.ts +0 -5
- package/dist/Alert/Alert.test.js +0 -74
- package/dist/App/App.d.ts +0 -12
- package/dist/App/App.js +0 -8
- package/dist/App/App.test.d.ts +0 -5
- package/dist/App/App.test.js +0 -33
- package/dist/App/index.d.ts +0 -6
- package/dist/App/index.js +0 -5
- package/dist/AppNavigation/AppNavigation.d.ts +0 -45
- package/dist/AppNavigation/AppNavigation.js +0 -18
- package/dist/AppNavigation/AppNavigation.test.d.ts +0 -5
- package/dist/AppNavigation/AppNavigation.test.js +0 -33
- package/dist/AppNavigation/AppNavigationButton.d.ts +0 -18
- package/dist/AppNavigation/AppNavigationButton.js +0 -17
- package/dist/AppNavigation/AppNavigationLink.d.ts +0 -19
- package/dist/AppNavigation/AppNavigationLink.js +0 -19
- package/dist/AppNavigation/AppNavigationMenu.d.ts +0 -9
- package/dist/AppNavigation/AppNavigationMenu.js +0 -5
- package/dist/AppNavigation/index.d.ts +0 -6
- package/dist/AppNavigation/index.js +0 -5
- package/dist/Avatar/Avatar.test.d.ts +0 -5
- package/dist/Avatar/Avatar.test.js +0 -63
- package/dist/Badge/Badge.test.d.ts +0 -5
- package/dist/Badge/Badge.test.js +0 -43
- package/dist/Blockquote/Blockquote.test.d.ts +0 -5
- package/dist/Blockquote/Blockquote.test.js +0 -46
- package/dist/Breadcrumb/Breadcrumb.test.d.ts +0 -5
- package/dist/Breadcrumb/Breadcrumb.test.js +0 -45
- package/dist/Breadcrumb/BreadcrumbLink.test.d.ts +0 -5
- package/dist/Breadcrumb/BreadcrumbLink.test.js +0 -40
- package/dist/Breakout/Breakout.test.d.ts +0 -5
- package/dist/Breakout/Breakout.test.js +0 -62
- package/dist/Breakout/BreakoutCell.test.d.ts +0 -5
- package/dist/Breakout/BreakoutCell.test.js +0 -128
- package/dist/Button/Button.test.d.ts +0 -5
- package/dist/Button/Button.test.js +0 -114
- package/dist/CallToActionLink/CallToActionLink.test.d.ts +0 -5
- package/dist/CallToActionLink/CallToActionLink.test.js +0 -33
- package/dist/Card/Card.test.d.ts +0 -5
- package/dist/Card/Card.test.js +0 -33
- package/dist/Card/CardHeading.test.d.ts +0 -5
- package/dist/Card/CardHeading.test.js +0 -38
- package/dist/Card/CardHeadingGroup.test.d.ts +0 -5
- package/dist/Card/CardHeadingGroup.test.js +0 -38
- package/dist/Card/CardImage.test.d.ts +0 -5
- package/dist/Card/CardImage.test.js +0 -33
- package/dist/Card/CardLink.test.d.ts +0 -5
- package/dist/Card/CardLink.test.js +0 -33
- package/dist/CharacterCount/CharacterCount.test.d.ts +0 -5
- package/dist/CharacterCount/CharacterCount.test.js +0 -38
- package/dist/Checkbox/Checkbox.test.d.ts +0 -5
- package/dist/Checkbox/Checkbox.test.js +0 -142
- package/dist/Column/Column.test.d.ts +0 -5
- package/dist/Column/Column.test.js +0 -59
- package/dist/DateInput/DateInput.test.d.ts +0 -5
- package/dist/DateInput/DateInput.test.js +0 -58
- package/dist/DescriptionList/DescriptionList.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionList.test.js +0 -43
- package/dist/DescriptionList/DescriptionListDescription.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListDescription.test.js +0 -33
- package/dist/DescriptionList/DescriptionListSection.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListSection.test.js +0 -33
- package/dist/DescriptionList/DescriptionListTerm.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListTerm.test.js +0 -33
- package/dist/Dialog/Dialog.test.d.ts +0 -5
- package/dist/Dialog/Dialog.test.js +0 -82
- package/dist/ErrorMessage/ErrorMessage.test.d.ts +0 -5
- package/dist/ErrorMessage/ErrorMessage.test.js +0 -53
- package/dist/Field/Field.test.d.ts +0 -5
- package/dist/Field/Field.test.js +0 -38
- package/dist/FieldSet/FieldSet.test.d.ts +0 -5
- package/dist/FieldSet/FieldSet.test.js +0 -70
- package/dist/Figure/Figure.test.d.ts +0 -5
- package/dist/Figure/Figure.test.js +0 -33
- package/dist/Figure/FigureCaption.test.d.ts +0 -5
- package/dist/Figure/FigureCaption.test.js +0 -38
- package/dist/FileInput/FileInput.test.d.ts +0 -5
- package/dist/FileInput/FileInput.test.js +0 -33
- package/dist/FileList/FileList.test.d.ts +0 -5
- package/dist/FileList/FileList.test.js +0 -33
- package/dist/FileList/FileListItem.test.d.ts +0 -5
- package/dist/FileList/FileListItem.test.js +0 -44
- package/dist/Grid/Grid.test.d.ts +0 -5
- package/dist/Grid/Grid.test.js +0 -69
- package/dist/Grid/GridCell.test.d.ts +0 -5
- package/dist/Grid/GridCell.test.js +0 -84
- package/dist/Heading/Heading.test.d.ts +0 -5
- package/dist/Heading/Heading.test.js +0 -70
- package/dist/Hint/Hint.test.d.ts +0 -5
- package/dist/Hint/Hint.test.js +0 -53
- package/dist/Icon/Icon.test.d.ts +0 -5
- package/dist/Icon/Icon.test.js +0 -60
- package/dist/IconButton/IconButton.test.d.ts +0 -5
- package/dist/IconButton/IconButton.test.js +0 -48
- package/dist/Image/Image.test.d.ts +0 -5
- package/dist/Image/Image.test.js +0 -43
- package/dist/ImageSlider/ImageSlider.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSlider.test.js +0 -70
- package/dist/ImageSlider/ImageSliderControls.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderControls.test.js +0 -25
- package/dist/ImageSlider/ImageSliderItem.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderItem.test.js +0 -37
- package/dist/ImageSlider/ImageSliderScroller.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderScroller.test.js +0 -37
- package/dist/ImageSlider/ImageSliderThumbnails.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderThumbnails.test.js +0 -52
- package/dist/InvalidFormAlert/InvalidFormAlert.test.d.ts +0 -5
- package/dist/InvalidFormAlert/InvalidFormAlert.test.js +0 -108
- package/dist/Label/Label.test.d.ts +0 -5
- package/dist/Label/Label.test.js +0 -82
- package/dist/Link/Link.test.d.ts +0 -5
- package/dist/Link/Link.test.js +0 -43
- package/dist/LinkList/LinkList.test.d.ts +0 -5
- package/dist/LinkList/LinkList.test.js +0 -33
- package/dist/LinkList/LinkListLink.test.d.ts +0 -5
- package/dist/LinkList/LinkListLink.test.js +0 -54
- package/dist/Logo/Logo.test.d.ts +0 -5
- package/dist/Logo/Logo.test.js +0 -33
- package/dist/Mark/Mark.test.d.ts +0 -5
- package/dist/Mark/Mark.test.js +0 -33
- package/dist/Menu/Menu.test.d.ts +0 -5
- package/dist/Menu/Menu.test.js +0 -55
- package/dist/Menu/MenuLink.test.d.ts +0 -5
- package/dist/Menu/MenuLink.test.js +0 -56
- package/dist/OrderedList/OrderedList.test.d.ts +0 -5
- package/dist/OrderedList/OrderedList.test.js +0 -55
- package/dist/OrderedList/OrderedListItem.test.d.ts +0 -5
- package/dist/OrderedList/OrderedListItem.test.js +0 -32
- package/dist/Overlap/Overlap.test.d.ts +0 -5
- package/dist/Overlap/Overlap.test.js +0 -38
- package/dist/Page/Page.test.d.ts +0 -5
- package/dist/Page/Page.test.js +0 -33
- package/dist/PageFooter/PageFooter.test.d.ts +0 -5
- package/dist/PageFooter/PageFooter.test.js +0 -33
- package/dist/PageFooter/PageFooterMenu.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterMenu.test.js +0 -35
- package/dist/PageFooter/PageFooterMenuLink.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterMenuLink.test.js +0 -33
- package/dist/PageFooter/PageFooterSpotlight.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterSpotlight.test.js +0 -33
- package/dist/PageHeader/PageHeader.test.d.ts +0 -6
- package/dist/PageHeader/PageHeader.test.js +0 -131
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.test.d.ts +0 -5
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.test.js +0 -38
- package/dist/PageHeader/PageHeaderMenuLink.test.d.ts +0 -5
- package/dist/PageHeader/PageHeaderMenuLink.test.js +0 -45
- package/dist/PageHeading/PageHeading.test.d.ts +0 -5
- package/dist/PageHeading/PageHeading.test.js +0 -40
- package/dist/Pagination/Pagination.test.d.ts +0 -5
- package/dist/Pagination/Pagination.test.js +0 -137
- package/dist/Paragraph/Paragraph.test.d.ts +0 -5
- package/dist/Paragraph/Paragraph.test.js +0 -62
- package/dist/PasswordInput/PasswordInput.test.d.ts +0 -5
- package/dist/PasswordInput/PasswordInput.test.js +0 -89
- package/dist/Radio/Radio.test.d.ts +0 -5
- package/dist/Radio/Radio.test.js +0 -134
- package/dist/Row/Row.test.d.ts +0 -5
- package/dist/Row/Row.test.js +0 -64
- package/dist/SearchField/SearchField.test.d.ts +0 -5
- package/dist/SearchField/SearchField.test.js +0 -33
- package/dist/SearchField/SearchFieldButton.test.d.ts +0 -5
- package/dist/SearchField/SearchFieldButton.test.js +0 -47
- package/dist/SearchField/SearchFieldInput.test.d.ts +0 -5
- package/dist/SearchField/SearchFieldInput.test.js +0 -65
- package/dist/Select/Select.test.d.ts +0 -5
- package/dist/Select/Select.test.js +0 -74
- package/dist/Select/SelectOption.test.d.ts +0 -5
- package/dist/Select/SelectOption.test.js +0 -45
- package/dist/Select/SelectOptionGroup.test.d.ts +0 -5
- package/dist/Select/SelectOptionGroup.test.js +0 -45
- package/dist/SkipLink/SkipLink.test.d.ts +0 -5
- package/dist/SkipLink/SkipLink.test.js +0 -33
- package/dist/Spotlight/Spotlight.test.d.ts +0 -5
- package/dist/Spotlight/Spotlight.test.js +0 -46
- package/dist/StandaloneLink/StandaloneLink.test.d.ts +0 -5
- package/dist/StandaloneLink/StandaloneLink.test.js +0 -46
- package/dist/Switch/Switch.test.d.ts +0 -5
- package/dist/Switch/Switch.test.js +0 -69
- package/dist/Table/Table.test.d.ts +0 -5
- package/dist/Table/Table.test.js +0 -33
- package/dist/Table/TableBody.test.d.ts +0 -5
- package/dist/Table/TableBody.test.js +0 -34
- package/dist/Table/TableCaption.test.d.ts +0 -5
- package/dist/Table/TableCaption.test.js +0 -45
- package/dist/Table/TableCell.test.d.ts +0 -5
- package/dist/Table/TableCell.test.js +0 -36
- package/dist/Table/TableFooter.test.d.ts +0 -5
- package/dist/Table/TableFooter.test.js +0 -34
- package/dist/Table/TableHeader.test.d.ts +0 -5
- package/dist/Table/TableHeader.test.js +0 -34
- package/dist/Table/TableHeaderCell.test.d.ts +0 -5
- package/dist/Table/TableHeaderCell.test.js +0 -42
- package/dist/Table/TableRow.test.d.ts +0 -5
- package/dist/Table/TableRow.test.js +0 -35
- package/dist/TableOfContents/TableOfContents.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContents.test.js +0 -44
- package/dist/TableOfContents/TableOfContentsLink.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContentsLink.test.js +0 -34
- package/dist/TableOfContents/TableOfContentsList.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContentsList.test.js +0 -40
- package/dist/Tabs/Tabs.test.d.ts +0 -5
- package/dist/Tabs/Tabs.test.js +0 -104
- package/dist/Tabs/TabsButton.test.d.ts +0 -5
- package/dist/Tabs/TabsButton.test.js +0 -57
- package/dist/Tabs/TabsList.test.d.ts +0 -5
- package/dist/Tabs/TabsList.test.js +0 -32
- package/dist/Tabs/TabsPanel.test.d.ts +0 -5
- package/dist/Tabs/TabsPanel.test.js +0 -42
- package/dist/TextArea/TextArea.test.d.ts +0 -5
- package/dist/TextArea/TextArea.test.js +0 -105
- package/dist/TextInput/TextInput.test.d.ts +0 -5
- package/dist/TextInput/TextInput.test.js +0 -92
- package/dist/TimeInput/TimeInput.test.d.ts +0 -5
- package/dist/TimeInput/TimeInput.test.js +0 -51
- package/dist/UnorderedList/UnorderedList.test.d.ts +0 -5
- package/dist/UnorderedList/UnorderedList.test.js +0 -55
- package/dist/UnorderedList/UnorderedListItem.test.d.ts +0 -5
- package/dist/UnorderedList/UnorderedListItem.test.js +0 -32
- package/dist/common/formatFileSize.test.d.ts +0 -5
- package/dist/common/formatFileSize.test.js +0 -22
- package/dist/common/formatFileType.test.d.ts +0 -5
- package/dist/common/formatFileType.test.js +0 -27
- package/dist/common/useKeyboardFocus.test.d.ts +0 -5
- package/dist/common/useKeyboardFocus.test.js +0 -79
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { InvalidFormAlert } from './InvalidFormAlert';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Invalid Form Alert', () => {
|
|
11
|
-
const testErrors = [
|
|
12
|
-
{ id: '#', label: 'Vul een geldige datum in (bijvoorbeeld 6 januari 2030).' },
|
|
13
|
-
{ id: '#', label: 'De geldigheidsdatum van uw paspoort moet in de toekomst liggen.' },
|
|
14
|
-
];
|
|
15
|
-
it('renders', () => {
|
|
16
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
17
|
-
const component = container.querySelector(':only-child');
|
|
18
|
-
expect(component).toBeInTheDocument();
|
|
19
|
-
expect(component).toBeVisible();
|
|
20
|
-
});
|
|
21
|
-
it('does not render when there are no errors', () => {
|
|
22
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: [], headingLevel: 2 }));
|
|
23
|
-
const component = container.querySelector(':only-child');
|
|
24
|
-
expect(component).not.toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
it('renders a design system BEM class name', () => {
|
|
27
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
28
|
-
const component = container.querySelector(':only-child');
|
|
29
|
-
expect(component).toHaveClass('ams-invalid-form-alert');
|
|
30
|
-
});
|
|
31
|
-
it('renders an extra class name', () => {
|
|
32
|
-
const { container } = render(_jsx(InvalidFormAlert, { className: "extra", errors: testErrors, headingLevel: 2 }));
|
|
33
|
-
const component = container.querySelector(':only-child');
|
|
34
|
-
expect(component).toHaveClass('ams-invalid-form-alert extra');
|
|
35
|
-
});
|
|
36
|
-
it('renders a list item and link for every error', () => {
|
|
37
|
-
render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
38
|
-
const listItems = screen.getAllByRole('listitem');
|
|
39
|
-
const links = screen.getAllByRole('link');
|
|
40
|
-
expect(listItems.length).toBe(2);
|
|
41
|
-
expect(links.length).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
it('renders a link with the correct name and href for every error', () => {
|
|
44
|
-
render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
45
|
-
const link1 = screen.getByRole('link', { name: testErrors[0].label });
|
|
46
|
-
const link2 = screen.getByRole('link', { name: testErrors[1].label });
|
|
47
|
-
expect(link1).toHaveAttribute('href', testErrors[0].id);
|
|
48
|
-
expect(link2).toHaveAttribute('href', testErrors[1].id);
|
|
49
|
-
});
|
|
50
|
-
it('renders a custom heading', () => {
|
|
51
|
-
render(_jsx(InvalidFormAlert, { errors: testErrors, heading: "Test heading", headingLevel: 2 }));
|
|
52
|
-
const component = screen.getByRole('heading', { name: 'Test heading' });
|
|
53
|
-
expect(component).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
it('renders the correct heading level', () => {
|
|
56
|
-
render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 4 }));
|
|
57
|
-
const component = screen.getByRole('heading', { level: 4 });
|
|
58
|
-
expect(component).toBeInTheDocument();
|
|
59
|
-
});
|
|
60
|
-
const docTitle = 'Document title';
|
|
61
|
-
const singleTestError = [{ id: '#', label: 'De geldigheidsdatum van uw paspoort moet in de toekomst liggen.' }];
|
|
62
|
-
describe('prepends the document title with the error count', () => {
|
|
63
|
-
it('single error', async () => {
|
|
64
|
-
document.title = docTitle;
|
|
65
|
-
render(_jsx(InvalidFormAlert, { errors: singleTestError, headingLevel: 2 }));
|
|
66
|
-
await waitFor(() => expect(document.title).toBe(`(1 invoerfout) ${docTitle}`));
|
|
67
|
-
});
|
|
68
|
-
it('multiple errors', async () => {
|
|
69
|
-
document.title = docTitle;
|
|
70
|
-
render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
71
|
-
await waitFor(() => expect(document.title).toBe(`(2 invoerfouten) ${docTitle}`));
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('renders a custom document title label', () => {
|
|
75
|
-
const label = { plural: 'errors', singular: 'error' };
|
|
76
|
-
it('no errors', async () => {
|
|
77
|
-
document.title = docTitle;
|
|
78
|
-
render(_jsx(InvalidFormAlert, { errors: [], headingLevel: 2 }));
|
|
79
|
-
await waitFor(() => expect(document.title).toBe(docTitle));
|
|
80
|
-
});
|
|
81
|
-
it('single error', async () => {
|
|
82
|
-
document.title = docTitle;
|
|
83
|
-
render(_jsx(InvalidFormAlert, { errorCountLabel: label, errors: singleTestError, headingLevel: 2 }));
|
|
84
|
-
await waitFor(() => expect(document.title).toBe(`(1 error) ${docTitle}`));
|
|
85
|
-
});
|
|
86
|
-
it('multiple errors', async () => {
|
|
87
|
-
document.title = docTitle;
|
|
88
|
-
render(_jsx(InvalidFormAlert, { errorCountLabel: label, errors: testErrors, headingLevel: 2 }));
|
|
89
|
-
await waitFor(() => expect(document.title).toBe(`(2 errors) ${docTitle}`));
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
it('has focus on render', async () => {
|
|
93
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2 }));
|
|
94
|
-
const component = container.querySelector(':only-child');
|
|
95
|
-
expect(component).toHaveFocus();
|
|
96
|
-
});
|
|
97
|
-
it('can disable automatic focus', async () => {
|
|
98
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: testErrors, focusOnRender: false, headingLevel: 2 }));
|
|
99
|
-
const component = container.querySelector(':only-child');
|
|
100
|
-
expect(component).not.toHaveFocus();
|
|
101
|
-
});
|
|
102
|
-
it('supports ForwardRef in React', () => {
|
|
103
|
-
const ref = createRef();
|
|
104
|
-
const { container } = render(_jsx(InvalidFormAlert, { errors: testErrors, headingLevel: 2, ref: ref }));
|
|
105
|
-
const component = container.querySelector(':only-child');
|
|
106
|
-
expect(ref.current).toBe(component);
|
|
107
|
-
});
|
|
108
|
-
});
|
package/dist/Label/Label.test.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Label } from './Label';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Label', () => {
|
|
11
|
-
it('renders an HTML label element', () => {
|
|
12
|
-
const { container } = render(_jsx(Label, { htmlFor: "form-control" }));
|
|
13
|
-
const label = container.querySelector('label:only-child');
|
|
14
|
-
expect(label).toBeInTheDocument();
|
|
15
|
-
expect(label).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders an HTML label element with for attribute', () => {
|
|
18
|
-
const { container } = render(_jsx(Label, { htmlFor: "form-control" }));
|
|
19
|
-
const label = container.querySelector('label[for="form-control"]:only-child');
|
|
20
|
-
expect(label).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
it('renders a design system BEM class name', () => {
|
|
23
|
-
const { container } = render(_jsx(Label, { htmlFor: "form-control" }));
|
|
24
|
-
const label = container.querySelector(':only-child');
|
|
25
|
-
expect(label).toHaveClass('ams-label');
|
|
26
|
-
});
|
|
27
|
-
it('renders rich text content', () => {
|
|
28
|
-
const { container } = render(_jsxs(Label, { htmlFor: "form-control", children: [_jsx("strong", { children: "Current" }), " password"] }));
|
|
29
|
-
const label = container.querySelector(':only-child');
|
|
30
|
-
const richText = label?.querySelector('strong');
|
|
31
|
-
expect(richText).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
it('can be associated with an HTML form input', () => {
|
|
34
|
-
render(_jsxs(_Fragment, { children: [_jsx(Label, { htmlFor: "email", children: "Email" }), _jsx("input", { id: "email", type: "email" })] }));
|
|
35
|
-
const textbox = screen.getByRole('textbox', {
|
|
36
|
-
name: 'Email',
|
|
37
|
-
});
|
|
38
|
-
expect(textbox).toBeInTheDocument();
|
|
39
|
-
expect(textbox).toBeVisible();
|
|
40
|
-
});
|
|
41
|
-
it('can be hidden', () => {
|
|
42
|
-
const { container } = render(_jsx(Label, { hidden: true, htmlFor: "form-control" }));
|
|
43
|
-
const label = container.querySelector(':only-child');
|
|
44
|
-
expect(label).not.toBeVisible();
|
|
45
|
-
});
|
|
46
|
-
it('renders an extra class name', () => {
|
|
47
|
-
const { container } = render(_jsx(Label, { className: "extra", htmlFor: "form-control" }));
|
|
48
|
-
const label = container.querySelector(':only-child');
|
|
49
|
-
expect(label).toHaveClass('ams-label extra');
|
|
50
|
-
});
|
|
51
|
-
it('supports ForwardRef in React', () => {
|
|
52
|
-
const ref = createRef();
|
|
53
|
-
const { container } = render(_jsx(Label, { htmlFor: "form-control", ref: ref }));
|
|
54
|
-
const div = container.querySelector(':only-child');
|
|
55
|
-
expect(ref.current).toBe(div);
|
|
56
|
-
});
|
|
57
|
-
it('renders the provided hint text after the label', () => {
|
|
58
|
-
const { container } = render(_jsx(Label, { hint: "hint text", htmlFor: "form-control", children: "Label" }));
|
|
59
|
-
const label = container.querySelector('label:only-child');
|
|
60
|
-
expect(label).toHaveTextContent('Label (hint text)');
|
|
61
|
-
});
|
|
62
|
-
it('renders the default hint text after the label', () => {
|
|
63
|
-
const { container } = render(_jsx(Label, { htmlFor: "form-control", optional: true, children: "Label" }));
|
|
64
|
-
const label = container.querySelector('label:only-child');
|
|
65
|
-
expect(label).toHaveTextContent('Label (niet verplicht)');
|
|
66
|
-
});
|
|
67
|
-
it('renders the provided hint text after the label when `optional` is set to `false`', () => {
|
|
68
|
-
const { container } = render(_jsx(Label, { hint: "not required", htmlFor: "form-control", optional: true, children: "Label" }));
|
|
69
|
-
const label = container.querySelector('label:only-child');
|
|
70
|
-
expect(label).toHaveTextContent('Label (not required)');
|
|
71
|
-
});
|
|
72
|
-
it('renders the provided hint text after the label while `optional` is set to `false`', () => {
|
|
73
|
-
const { container } = render(_jsx(Label, { hint: "required", htmlFor: "form-control", optional: false, children: "Label" }));
|
|
74
|
-
const label = container.querySelector('label:only-child');
|
|
75
|
-
expect(label).toHaveTextContent('Label (required)');
|
|
76
|
-
});
|
|
77
|
-
it('renders a Heading component', () => {
|
|
78
|
-
render(_jsx(Label, { isPageHeading: true, children: "Label" }));
|
|
79
|
-
const heading = screen.getByRole('heading', { name: 'Label' });
|
|
80
|
-
expect(heading).toBeInTheDocument();
|
|
81
|
-
});
|
|
82
|
-
});
|
package/dist/Link/Link.test.d.ts
DELETED
package/dist/Link/Link.test.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Link } from './Link';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Link', () => {
|
|
11
|
-
it('renders with href attribute', () => {
|
|
12
|
-
render(_jsx(Link, { href: "#" }));
|
|
13
|
-
const component = screen.getByRole('link');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toHaveAttribute('href', '#');
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(Link, { href: "#" }));
|
|
19
|
-
const component = screen.getByRole('link');
|
|
20
|
-
expect(component).toHaveClass('ams-link');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(Link, { className: "extra", href: "#" }));
|
|
24
|
-
const component = screen.getByRole('link');
|
|
25
|
-
expect(component).toHaveClass('ams-link extra');
|
|
26
|
-
});
|
|
27
|
-
it('renders the class name for contrast color', () => {
|
|
28
|
-
render(_jsx(Link, { color: "contrast", href: "#" }));
|
|
29
|
-
const component = screen.getByRole('link');
|
|
30
|
-
expect(component).toHaveClass('ams-link ams-link--contrast');
|
|
31
|
-
});
|
|
32
|
-
it('renders the class name for inverse color', () => {
|
|
33
|
-
render(_jsx(Link, { color: "inverse", href: "#" }));
|
|
34
|
-
const component = screen.getByRole('link');
|
|
35
|
-
expect(component).toHaveClass('ams-link ams-link--inverse');
|
|
36
|
-
});
|
|
37
|
-
it('supports ForwardRef in React', () => {
|
|
38
|
-
const ref = createRef();
|
|
39
|
-
render(_jsx(Link, { href: "#", ref: ref }));
|
|
40
|
-
const component = screen.getByRole('link');
|
|
41
|
-
expect(ref.current).toBe(component);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import '@testing-library/jest-dom';
|
|
7
|
-
import { render, screen } from '@testing-library/react';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { LinkList } from './LinkList';
|
|
10
|
-
describe('Link list', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(LinkList, {}));
|
|
13
|
-
const component = screen.getByRole('list');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(LinkList, {}));
|
|
19
|
-
const component = screen.getByRole('list');
|
|
20
|
-
expect(component).toHaveClass('ams-link-list');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(LinkList, { className: "extra" }));
|
|
24
|
-
const component = screen.getByRole('list');
|
|
25
|
-
expect(component).toHaveClass('ams-link-list extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
render(_jsx(LinkList, { ref: ref }));
|
|
30
|
-
const component = screen.getByRole('list');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import '@testing-library/jest-dom';
|
|
7
|
-
import { render, screen } from '@testing-library/react';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { LinkList } from './LinkList';
|
|
10
|
-
describe('Link list link', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(LinkList.Link, { href: "#" }));
|
|
13
|
-
const listItem = screen.getByRole('listitem');
|
|
14
|
-
const link = screen.getByRole('link');
|
|
15
|
-
const icon = container.querySelector('svg');
|
|
16
|
-
expect(listItem).toBeInTheDocument();
|
|
17
|
-
expect(listItem).toBeVisible();
|
|
18
|
-
expect(link).toBeInTheDocument();
|
|
19
|
-
expect(link).toBeVisible();
|
|
20
|
-
expect(icon).toBeInTheDocument();
|
|
21
|
-
expect(icon).not.toBeVisible(); // The icon is hidden by default, and only shown when the CSS loads.
|
|
22
|
-
});
|
|
23
|
-
it('renders a design system BEM class name', () => {
|
|
24
|
-
render(_jsx(LinkList.Link, { href: "#" }));
|
|
25
|
-
const component = screen.getByRole('link');
|
|
26
|
-
expect(component).toHaveClass('ams-link-list__link');
|
|
27
|
-
});
|
|
28
|
-
it('renders an extra class name', () => {
|
|
29
|
-
render(_jsx(LinkList.Link, { className: "extra", href: "#" }));
|
|
30
|
-
const component = screen.getByRole('link');
|
|
31
|
-
expect(component).toHaveClass('ams-link-list__link extra');
|
|
32
|
-
});
|
|
33
|
-
it('renders a class name for the small size', () => {
|
|
34
|
-
render(_jsx(LinkList.Link, { href: "#", size: "small" }));
|
|
35
|
-
const component = screen.getByRole('link');
|
|
36
|
-
expect(component).toHaveClass('ams-link-list__link--small');
|
|
37
|
-
});
|
|
38
|
-
it('renders the class name for contrast color', () => {
|
|
39
|
-
render(_jsx(LinkList.Link, { color: "contrast", href: "#" }));
|
|
40
|
-
const component = screen.getByRole('link');
|
|
41
|
-
expect(component).toHaveClass('ams-link-list__link--contrast');
|
|
42
|
-
});
|
|
43
|
-
it('renders the class name for inverse color', () => {
|
|
44
|
-
render(_jsx(LinkList.Link, { color: "inverse", href: "#" }));
|
|
45
|
-
const component = screen.getByRole('link');
|
|
46
|
-
expect(component).toHaveClass('ams-link-list__link--inverse');
|
|
47
|
-
});
|
|
48
|
-
it('supports ForwardRef in React', () => {
|
|
49
|
-
const ref = createRef();
|
|
50
|
-
render(_jsx(LinkList.Link, { href: "#", ref: ref }));
|
|
51
|
-
const component = screen.getByRole('link');
|
|
52
|
-
expect(ref.current).toBe(component);
|
|
53
|
-
});
|
|
54
|
-
});
|
package/dist/Logo/Logo.test.d.ts
DELETED
package/dist/Logo/Logo.test.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Logo } from './Logo';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Logo', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(Logo, {}));
|
|
13
|
-
const component = container.querySelector(':only-child');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
const { container } = render(_jsx(Logo, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-logo');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(Logo, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-logo extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(Logo, { ref: ref }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/dist/Mark/Mark.test.d.ts
DELETED
package/dist/Mark/Mark.test.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Mark } from './Mark';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Mark', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(Mark, {}));
|
|
13
|
-
const component = container.querySelector(':only-child');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
const { container } = render(_jsx(Mark, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-mark');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(Mark, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-mark extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(Mark, { ref: ref }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/dist/Menu/Menu.test.d.ts
DELETED
package/dist/Menu/Menu.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Menu } from './Menu';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Menu', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(Menu, {}));
|
|
13
|
-
const component = container.querySelector(':only-child');
|
|
14
|
-
const list = screen.getByRole('list');
|
|
15
|
-
expect(component).toBeInTheDocument();
|
|
16
|
-
expect(component).toBeVisible();
|
|
17
|
-
expect(component).toContainElement(list);
|
|
18
|
-
});
|
|
19
|
-
it('renders a design system BEM class name', () => {
|
|
20
|
-
const { container } = render(_jsx(Menu, {}));
|
|
21
|
-
const component = container.querySelector(':only-child');
|
|
22
|
-
expect(component).toHaveClass('ams-menu');
|
|
23
|
-
});
|
|
24
|
-
it('renders an extra class name', () => {
|
|
25
|
-
const { container } = render(_jsx(Menu, { className: "extra" }));
|
|
26
|
-
const component = container.querySelector(':only-child');
|
|
27
|
-
expect(component).toHaveClass('ams-menu extra');
|
|
28
|
-
});
|
|
29
|
-
it('renders a `nav` element with the `inWideWindow` prop', () => {
|
|
30
|
-
render(_jsx(Menu, { inWideWindow: true }));
|
|
31
|
-
const component = screen.getByRole('navigation');
|
|
32
|
-
expect(component).toBeInTheDocument();
|
|
33
|
-
});
|
|
34
|
-
it('renders the class name for the `inWideWindow` prop', () => {
|
|
35
|
-
const { container } = render(_jsx(Menu, { inWideWindow: true }));
|
|
36
|
-
const component = container.querySelector(':only-child');
|
|
37
|
-
expect(component).toHaveClass('ams-menu--in-wide-window');
|
|
38
|
-
});
|
|
39
|
-
it('supports ForwardRef in React', () => {
|
|
40
|
-
const ref = createRef();
|
|
41
|
-
const { container } = render(_jsx(Menu, { ref: ref }));
|
|
42
|
-
const component = container.querySelector(':only-child');
|
|
43
|
-
expect(ref.current).toBe(component);
|
|
44
|
-
});
|
|
45
|
-
it('renders a custom accessible name', () => {
|
|
46
|
-
render(_jsx(Menu, { accessibleName: "Custom accessible name", inWideWindow: true }));
|
|
47
|
-
const component = screen.getByRole('navigation', { name: 'Custom accessible name' });
|
|
48
|
-
expect(component).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
it('doesn’t render a custom accessible name if not in a wide window', () => {
|
|
51
|
-
render(_jsx(Menu, { accessibleName: "Custom accessible name" }));
|
|
52
|
-
const component = screen.queryByRole('navigation', { name: 'Custom accessible name' });
|
|
53
|
-
expect(component).not.toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import '@testing-library/jest-dom';
|
|
7
|
-
import { DocumentIcon, StarIcon } from '@amsterdam/design-system-react-icons';
|
|
8
|
-
import { render, screen } from '@testing-library/react';
|
|
9
|
-
import { createRef } from 'react';
|
|
10
|
-
import { Menu } from './Menu';
|
|
11
|
-
describe('Menu Link', () => {
|
|
12
|
-
it('renders', () => {
|
|
13
|
-
const { container } = render(_jsx(Menu.Link, { href: "#", icon: DocumentIcon }));
|
|
14
|
-
const listItem = screen.getByRole('listitem');
|
|
15
|
-
const link = screen.getByRole('link');
|
|
16
|
-
const icon = container.querySelector('svg');
|
|
17
|
-
expect(listItem).toBeInTheDocument();
|
|
18
|
-
expect(listItem).toBeVisible();
|
|
19
|
-
expect(link).toBeInTheDocument();
|
|
20
|
-
expect(link).toBeVisible();
|
|
21
|
-
expect(icon).toBeInTheDocument();
|
|
22
|
-
expect(icon).not.toBeVisible(); // The icon is hidden by default, and only shown when the CSS loads.
|
|
23
|
-
});
|
|
24
|
-
it('renders a design system BEM class name', () => {
|
|
25
|
-
render(_jsx(Menu.Link, { href: "#", icon: DocumentIcon }));
|
|
26
|
-
const component = screen.getByRole('link');
|
|
27
|
-
expect(component).toHaveClass('ams-menu__link');
|
|
28
|
-
});
|
|
29
|
-
it('renders an extra class name', () => {
|
|
30
|
-
render(_jsx(Menu.Link, { className: "extra", href: "#", icon: DocumentIcon }));
|
|
31
|
-
const component = screen.getByRole('link');
|
|
32
|
-
expect(component).toHaveClass('ams-menu__link extra');
|
|
33
|
-
});
|
|
34
|
-
it('renders the class name for contrast color', () => {
|
|
35
|
-
render(_jsx(Menu.Link, { color: "contrast", href: "#", icon: DocumentIcon }));
|
|
36
|
-
const component = screen.getByRole('link');
|
|
37
|
-
expect(component).toHaveClass('ams-menu__link--contrast');
|
|
38
|
-
});
|
|
39
|
-
it('renders the class name for inverse color', () => {
|
|
40
|
-
render(_jsx(Menu.Link, { color: "inverse", href: "#", icon: DocumentIcon }));
|
|
41
|
-
const component = screen.getByRole('link');
|
|
42
|
-
expect(component).toHaveClass('ams-menu__link--inverse');
|
|
43
|
-
});
|
|
44
|
-
it('supports ForwardRef in React', () => {
|
|
45
|
-
const ref = createRef();
|
|
46
|
-
render(_jsx(Menu.Link, { href: "#", icon: DocumentIcon, ref: ref }));
|
|
47
|
-
const component = screen.getByRole('link');
|
|
48
|
-
expect(ref.current).toBe(component);
|
|
49
|
-
});
|
|
50
|
-
it('shows a custom icon', () => {
|
|
51
|
-
render(_jsx(Menu.Link, { href: "#", icon: _jsx(StarIcon, { className: "test-class" }) }));
|
|
52
|
-
const component = screen.getByRole('link');
|
|
53
|
-
const icon = component.querySelector('.test-class');
|
|
54
|
-
expect(icon).toBeInTheDocument();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { OrderedList } from './OrderedList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Ordered list', () => {
|
|
11
|
-
it('renders an HTML ol element', () => {
|
|
12
|
-
const { container } = render(_jsx(OrderedList, {}));
|
|
13
|
-
const list = container.querySelector('ol:only-child');
|
|
14
|
-
expect(list).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
it('renders a design system BEM class name', () => {
|
|
17
|
-
render(_jsx(OrderedList, {}));
|
|
18
|
-
const component = screen.getByRole('list');
|
|
19
|
-
expect(component).toHaveClass('ams-ordered-list');
|
|
20
|
-
});
|
|
21
|
-
it('renders a no markers class', () => {
|
|
22
|
-
render(_jsx(OrderedList, { markers: false }));
|
|
23
|
-
const component = screen.getByRole('list');
|
|
24
|
-
expect(component).toHaveClass('ams-ordered-list--no-markers');
|
|
25
|
-
});
|
|
26
|
-
it('renders the class name for inverse color', () => {
|
|
27
|
-
render(_jsx(OrderedList, { color: "inverse" }));
|
|
28
|
-
const component = screen.getByRole('list');
|
|
29
|
-
expect(component).toHaveClass('ams-ordered-list--inverse');
|
|
30
|
-
});
|
|
31
|
-
it('renders an extra class name', () => {
|
|
32
|
-
render(_jsx(OrderedList, { className: "extra" }));
|
|
33
|
-
const component = screen.getByRole('list');
|
|
34
|
-
expect(component).toHaveClass('ams-ordered-list extra');
|
|
35
|
-
});
|
|
36
|
-
it('renders its subcomponent', () => {
|
|
37
|
-
const listItems = ['Item 1', 'Item 2', 'Item 3'];
|
|
38
|
-
const { container } = render(_jsx(OrderedList, { children: listItems.map((item) => (_jsx(OrderedList.Item, { children: item }, item))) }));
|
|
39
|
-
const list = screen.getByRole('list');
|
|
40
|
-
const items = container.querySelectorAll('.ams-ordered-list__item');
|
|
41
|
-
expect(list).toBeInTheDocument();
|
|
42
|
-
expect(items.length).toBe(3);
|
|
43
|
-
});
|
|
44
|
-
it('renders the small size class', () => {
|
|
45
|
-
render(_jsx(OrderedList, { size: "small" }));
|
|
46
|
-
const component = screen.getByRole('list');
|
|
47
|
-
expect(component).toHaveClass('ams-ordered-list--small');
|
|
48
|
-
});
|
|
49
|
-
it('supports ForwardRef in React', () => {
|
|
50
|
-
const ref = createRef();
|
|
51
|
-
render(_jsx(OrderedList, { ref: ref }));
|
|
52
|
-
const component = screen.getByRole('list');
|
|
53
|
-
expect(ref.current).toBe(component);
|
|
54
|
-
});
|
|
55
|
-
});
|