@amsterdam/design-system-react 2.0.2 → 2.2.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/dist/Accordion/Accordion.d.ts +3 -3
- package/dist/Accordion/AccordionSection.d.ts +5 -5
- package/dist/Avatar/Avatar.d.ts +2 -2
- package/dist/Badge/Badge.d.ts +4 -4
- package/dist/Blockquote/Blockquote.d.ts +5 -5
- package/dist/Breakout/BreakoutCell.d.ts +2 -2
- package/dist/Button/Button.d.ts +7 -5
- package/dist/Button/Button.js +1 -0
- package/dist/Card/Card.d.ts +8 -8
- package/dist/Card/CardHeading.d.ts +3 -3
- package/dist/Card/CardHeadingGroup.d.ts +5 -5
- package/dist/Card/CardImage.d.ts +2 -2
- package/dist/Checkbox/Checkbox.d.ts +5 -5
- package/dist/Column/Column.d.ts +5 -5
- package/dist/DateInput/DateInput.d.ts +4 -4
- package/dist/DescriptionList/DescriptionList.d.ts +5 -5
- package/dist/Dialog/Dialog.d.ts +6 -7
- package/dist/Field/Field.d.ts +5 -5
- package/dist/FieldSet/FieldSet.d.ts +31 -10
- package/dist/FieldSet/FieldSet.js +4 -3
- package/dist/Figure/Figure.d.ts +3 -3
- package/dist/Figure/FigureCaption.d.ts +5 -5
- package/dist/FileList/FileList.d.ts +2 -2
- package/dist/FileList/FileListItem.d.ts +4 -4
- package/dist/Grid/Grid.d.ts +2 -2
- package/dist/Grid/GridCell.d.ts +2 -2
- package/dist/Heading/Heading.d.ts +10 -11
- package/dist/Heading/Heading.js +1 -0
- package/dist/Hint/Hint.d.ts +1 -0
- package/dist/Hint/Hint.js +2 -2
- package/dist/Icon/Icon.d.ts +0 -4
- package/dist/IconButton/IconButton.d.ts +4 -2
- package/dist/IconButton/IconButton.js +1 -0
- package/dist/Image/Image.d.ts +5 -5
- package/dist/Image/Image.js +1 -1
- package/dist/ImageSlider/ImageSlider.d.ts +4 -4
- package/dist/ImageSlider/ImageSliderItem.d.ts +5 -5
- package/dist/ImageSlider/ImageSliderThumbnails.d.ts +5 -5
- package/dist/InvalidFormAlert/InvalidFormAlertWithErrors.d.ts +2 -2
- package/dist/Label/Label.d.ts +25 -6
- package/dist/Label/Label.js +3 -2
- package/dist/Link/Link.d.ts +4 -4
- package/dist/LinkList/LinkList.d.ts +1 -1
- package/dist/LinkList/LinkListLink.d.ts +9 -4
- package/dist/LinkList/LinkListLink.js +2 -0
- package/dist/Logo/Logo.d.ts +2 -2
- package/dist/Menu/Menu.d.ts +31 -10
- package/dist/Menu/Menu.js +6 -1
- package/dist/Menu/MenuLink.d.ts +10 -4
- package/dist/OrderedList/OrderedList.d.ts +5 -5
- package/dist/Page/Page.d.ts +6 -2
- package/dist/Page/Page.js +1 -1
- package/dist/PageHeader/PageHeader.d.ts +8 -7
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.d.ts +1 -1
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +0 -4
- package/dist/PageHeader/PageHeaderMenuIcon.js +1 -1
- package/dist/PageHeader/PageHeaderMenuLink.d.ts +13 -6
- package/dist/PageHeader/PageHeaderMenuLink.js +3 -6
- package/dist/PageHeading/PageHeading.d.ts +5 -5
- package/dist/Pagination/LinkItem.d.ts +3 -3
- package/dist/Pagination/Pagination.d.ts +4 -4
- package/dist/Paragraph/Paragraph.d.ts +5 -9
- package/dist/PasswordInput/PasswordInput.d.ts +4 -4
- package/dist/Radio/Radio.d.ts +5 -5
- package/dist/Row/Row.d.ts +5 -5
- package/dist/SearchField/SearchField.d.ts +2 -2
- package/dist/SearchField/SearchFieldButton.js +1 -1
- package/dist/SearchField/SearchFieldInput.d.ts +2 -2
- package/dist/Select/Select.d.ts +5 -5
- package/dist/Spotlight/Spotlight.d.ts +6 -6
- package/dist/Spotlight/Spotlight.js +0 -4
- package/dist/StandaloneLink/StandaloneLink.d.ts +4 -4
- package/dist/Table/TableCaption.d.ts +0 -4
- package/dist/TableOfContents/TableOfContents.d.ts +7 -7
- package/dist/TableOfContents/TableOfContentsLink.d.ts +4 -4
- package/dist/Tabs/Tabs.d.ts +11 -11
- package/dist/Tabs/TabsButton.d.ts +5 -5
- package/dist/Tabs/TabsPanel.d.ts +5 -5
- package/dist/TextArea/TextArea.d.ts +12 -6
- package/dist/TextInput/TextInput.d.ts +4 -4
- package/dist/TimeInput/TimeInput.d.ts +4 -4
- package/dist/UnorderedList/UnorderedList.d.ts +5 -5
- package/dist/common/useIsAfterBreakpoint.d.ts +4 -0
- package/dist/common/useIsAfterBreakpoint.js +4 -4
- package/dist/index.cjs.js +62 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +293 -218
- package/dist/index.esm.js +62 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +21 -20
- 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/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 -63
- 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 -77
- 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 -38
- 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 -135
- 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 -50
- 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,142 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { StarIcon } from '@amsterdam/design-system-react-icons';
|
|
7
|
-
import { render, screen } from '@testing-library/react';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { Checkbox } from './Checkbox';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
describe('Checkbox', () => {
|
|
12
|
-
it('renders', () => {
|
|
13
|
-
const { container } = render(_jsx(Checkbox, {}));
|
|
14
|
-
const wrapper = container.querySelector(':only-child');
|
|
15
|
-
const input = screen.getByRole('checkbox');
|
|
16
|
-
const label = container.querySelector('label');
|
|
17
|
-
expect(wrapper).toBeInTheDocument();
|
|
18
|
-
expect(wrapper).toBeVisible();
|
|
19
|
-
expect(input).toBeInTheDocument();
|
|
20
|
-
expect(input).toBeVisible();
|
|
21
|
-
expect(label).toBeInTheDocument();
|
|
22
|
-
expect(label).toBeVisible();
|
|
23
|
-
});
|
|
24
|
-
it('renders a design system BEM class name', () => {
|
|
25
|
-
const { container } = render(_jsx(Checkbox, {}));
|
|
26
|
-
const wrapper = container.querySelector(':only-child');
|
|
27
|
-
const input = screen.getByRole('checkbox');
|
|
28
|
-
const label = container.querySelector('label');
|
|
29
|
-
expect(wrapper).toHaveClass('ams-checkbox');
|
|
30
|
-
expect(input).toHaveClass('ams-checkbox__input');
|
|
31
|
-
expect(label).toHaveClass('ams-checkbox__label');
|
|
32
|
-
});
|
|
33
|
-
it('renders an extra class name', () => {
|
|
34
|
-
const { container } = render(_jsx(Checkbox, { className: "extra" }));
|
|
35
|
-
const wrapper = container.querySelector(':only-child');
|
|
36
|
-
expect(wrapper).toHaveClass('ams-checkbox extra');
|
|
37
|
-
});
|
|
38
|
-
describe('Checked state', () => {
|
|
39
|
-
it('is not checked by default', () => {
|
|
40
|
-
render(_jsx(Checkbox, {}));
|
|
41
|
-
const input = screen.getByRole('checkbox');
|
|
42
|
-
expect(input).not.toBeChecked();
|
|
43
|
-
});
|
|
44
|
-
it('can have a checked state', () => {
|
|
45
|
-
const handleChange = () => { };
|
|
46
|
-
render(_jsx(Checkbox, { checked: true, onChange: handleChange }));
|
|
47
|
-
const input = screen.getByRole('checkbox');
|
|
48
|
-
expect(input).toBeChecked();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('Indeterminate state', () => {
|
|
52
|
-
it('is not indeterminate by default', () => {
|
|
53
|
-
render(_jsx(Checkbox, {}));
|
|
54
|
-
const input = screen.getByRole('checkbox');
|
|
55
|
-
expect(input).not.toBePartiallyChecked();
|
|
56
|
-
});
|
|
57
|
-
it('can have an indeterminate state', () => {
|
|
58
|
-
render(_jsx(Checkbox, { indeterminate: true }));
|
|
59
|
-
const input = screen.getByRole('checkbox');
|
|
60
|
-
expect(input).toBePartiallyChecked();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('Invalid state', () => {
|
|
64
|
-
it('is not invalid by default', () => {
|
|
65
|
-
render(_jsx(Checkbox, {}));
|
|
66
|
-
const input = screen.getByRole('checkbox');
|
|
67
|
-
expect(input).not.toBeInvalid();
|
|
68
|
-
});
|
|
69
|
-
it('can have an invalid state', () => {
|
|
70
|
-
render(_jsx(Checkbox, { invalid: true }));
|
|
71
|
-
const input = screen.getByRole('checkbox');
|
|
72
|
-
expect(input).toHaveAttribute('aria-invalid');
|
|
73
|
-
expect(input).toBeInvalid();
|
|
74
|
-
});
|
|
75
|
-
it('omits non-essential invalid attributes when not invalid', () => {
|
|
76
|
-
render(_jsx(Checkbox, { invalid: false }));
|
|
77
|
-
const input = screen.getByRole('checkbox');
|
|
78
|
-
expect(input).not.toHaveAttribute('aria-invalid');
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('Disabled state', () => {
|
|
82
|
-
it('is not disabled by default', () => {
|
|
83
|
-
render(_jsx(Checkbox, {}));
|
|
84
|
-
const input = screen.getByRole('checkbox');
|
|
85
|
-
expect(input).not.toBeDisabled();
|
|
86
|
-
});
|
|
87
|
-
it('can have a disabled state', () => {
|
|
88
|
-
render(_jsx(Checkbox, { disabled: true }));
|
|
89
|
-
const input = screen.getByRole('checkbox');
|
|
90
|
-
expect(input).toBeDisabled();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
describe('Disabled invalid state', () => {
|
|
94
|
-
it('can have a disabled invalid state', () => {
|
|
95
|
-
render(_jsx(Checkbox, { disabled: true, invalid: true }));
|
|
96
|
-
const input = screen.getByRole('checkbox');
|
|
97
|
-
expect(input).toBeDisabled();
|
|
98
|
-
expect(input).toBeInvalid();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
it('can trigger a change event', () => {
|
|
102
|
-
const handleChange = jest.fn();
|
|
103
|
-
render(_jsx(Checkbox, { onChange: handleChange }));
|
|
104
|
-
const input = screen.getByRole('checkbox');
|
|
105
|
-
input?.click();
|
|
106
|
-
expect(handleChange).toHaveBeenCalled();
|
|
107
|
-
});
|
|
108
|
-
it('does not trigger a change event when disabled', () => {
|
|
109
|
-
const handleChange = jest.fn();
|
|
110
|
-
render(_jsx(Checkbox, { disabled: true, onChange: handleChange }));
|
|
111
|
-
const input = screen.getByRole('checkbox');
|
|
112
|
-
input?.click();
|
|
113
|
-
expect(handleChange).not.toHaveBeenCalled();
|
|
114
|
-
});
|
|
115
|
-
it('can trigger a change event by clicking on label', () => {
|
|
116
|
-
const handleChange = jest.fn();
|
|
117
|
-
const { container } = render(_jsx(Checkbox, { onChange: handleChange }));
|
|
118
|
-
const label = container.querySelector('label');
|
|
119
|
-
label?.click();
|
|
120
|
-
expect(handleChange).toHaveBeenCalled();
|
|
121
|
-
});
|
|
122
|
-
it('can use a custom id', () => {
|
|
123
|
-
const handleChange = jest.fn();
|
|
124
|
-
const { container } = render(_jsx(Checkbox, { id: "test-id", onChange: handleChange }));
|
|
125
|
-
const input = screen.getByRole('checkbox');
|
|
126
|
-
expect(input).toHaveAttribute('id', 'test-id');
|
|
127
|
-
const label = container.querySelector('label');
|
|
128
|
-
label?.click();
|
|
129
|
-
expect(handleChange).toHaveBeenCalled();
|
|
130
|
-
});
|
|
131
|
-
it('shows a custom icon', () => {
|
|
132
|
-
const { container } = render(_jsx(Checkbox, { icon: _jsx(StarIcon, { className: "test-class" }) }));
|
|
133
|
-
const icon = container.querySelector('svg');
|
|
134
|
-
expect(icon).toHaveClass('test-class');
|
|
135
|
-
});
|
|
136
|
-
it('supports ForwardRef in React', () => {
|
|
137
|
-
const ref = createRef();
|
|
138
|
-
render(_jsx(Checkbox, { ref: ref }));
|
|
139
|
-
const input = screen.getByRole('checkbox');
|
|
140
|
-
expect(ref.current).toBe(input);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
@@ -1,59 +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 { ariaRoleForTag } from '../common/accessibility';
|
|
9
|
-
import { crossAlignOptionsForColumn, mainAlignOptions } from '../common/types';
|
|
10
|
-
import { Column, columnGapSizes, columnTags } from './Column';
|
|
11
|
-
import '@testing-library/jest-dom';
|
|
12
|
-
describe('Column', () => {
|
|
13
|
-
it('renders', () => {
|
|
14
|
-
const { container } = render(_jsx(Column, {}));
|
|
15
|
-
const component = container.querySelector(':only-child');
|
|
16
|
-
expect(component).toBeInTheDocument();
|
|
17
|
-
expect(component).toBeVisible();
|
|
18
|
-
});
|
|
19
|
-
it('renders a design system BEM class name', () => {
|
|
20
|
-
const { container } = render(_jsx(Column, {}));
|
|
21
|
-
const component = container.querySelector(':only-child');
|
|
22
|
-
expect(component).toHaveClass('ams-column');
|
|
23
|
-
});
|
|
24
|
-
columnGapSizes.map((gap) => it(`renders with ‘${gap}’ gap`, () => {
|
|
25
|
-
const { container } = render(_jsx(Column, { gap: gap }));
|
|
26
|
-
const component = container.querySelector(':only-child');
|
|
27
|
-
expect(component).toHaveClass(`ams-column--gap-${gap}`);
|
|
28
|
-
}));
|
|
29
|
-
it('renders an extra class name', () => {
|
|
30
|
-
const { container } = render(_jsx(Column, { className: "extra" }));
|
|
31
|
-
const component = container.querySelector(':only-child');
|
|
32
|
-
expect(component).toHaveClass('ams-column extra');
|
|
33
|
-
});
|
|
34
|
-
columnTags.forEach((tag) => {
|
|
35
|
-
it(`renders with a custom ${tag} tag`, () => {
|
|
36
|
-
const { container } = render(_jsx(Column, { "aria-label": tag === 'section' ? 'Accessible name' : undefined, as: tag }));
|
|
37
|
-
const component = tag === 'div' ? container.querySelector(tag) : screen.getByRole(ariaRoleForTag[tag]);
|
|
38
|
-
expect(component).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
it('supports ForwardRef in React', () => {
|
|
42
|
-
const ref = createRef();
|
|
43
|
-
const { container } = render(_jsx(Column, { ref: ref }));
|
|
44
|
-
const component = container.querySelector(':only-child');
|
|
45
|
-
expect(ref.current).toBe(component);
|
|
46
|
-
});
|
|
47
|
-
describe('Alignment', () => {
|
|
48
|
-
mainAlignOptions.map((align) => it(`sets the ‘${align}’ alignment`, () => {
|
|
49
|
-
const { container } = render(_jsx(Column, { align: align }));
|
|
50
|
-
const component = container.querySelector(':only-child');
|
|
51
|
-
expect(component).toHaveClass(`ams-column--align-${align}`);
|
|
52
|
-
}));
|
|
53
|
-
crossAlignOptionsForColumn.map((align) => it(`sets the ‘${align}’ vertical alignment`, () => {
|
|
54
|
-
const { container } = render(_jsx(Column, { alignHorizontal: align }));
|
|
55
|
-
const component = container.querySelector(':only-child');
|
|
56
|
-
expect(component).toHaveClass(`ams-column--align-horizontal-${align}`);
|
|
57
|
-
}));
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,58 +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 { DateInput, dateInputTypes } from './DateInput';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Date input', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(DateInput, {}));
|
|
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(DateInput, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-date-input');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(DateInput, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-date-input extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(DateInput, { ref: ref }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
describe('Invalid state', () => {
|
|
34
|
-
it('is not invalid by default', () => {
|
|
35
|
-
const { container } = render(_jsx(DateInput, {}));
|
|
36
|
-
const component = container.querySelector(':only-child');
|
|
37
|
-
expect(component).not.toBeInvalid();
|
|
38
|
-
});
|
|
39
|
-
it('can have an invalid state', () => {
|
|
40
|
-
const { container } = render(_jsx(DateInput, { invalid: true }));
|
|
41
|
-
const component = container.querySelector(':only-child');
|
|
42
|
-
expect(component).toHaveAttribute('aria-invalid');
|
|
43
|
-
expect(component).toBeInvalid();
|
|
44
|
-
});
|
|
45
|
-
it('omits non-essential invalid attributes when not invalid', () => {
|
|
46
|
-
const { container } = render(_jsx(DateInput, { invalid: false }));
|
|
47
|
-
const component = container.querySelector(':only-child');
|
|
48
|
-
expect(component).not.toHaveAttribute('aria-invalid');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('Type', () => {
|
|
52
|
-
dateInputTypes.map((type) => it(`sets the ‘${type}’ type`, () => {
|
|
53
|
-
const { container } = render(_jsx(DateInput, { type: type }));
|
|
54
|
-
const component = container.querySelector(':only-child');
|
|
55
|
-
expect(component).toHaveAttribute('type', type);
|
|
56
|
-
}));
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -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 } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { DescriptionList, descriptionListTermsWidths } from './DescriptionList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Description List', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(DescriptionList, {}));
|
|
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(DescriptionList, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-description-list');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(DescriptionList, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-description-list extra');
|
|
26
|
-
});
|
|
27
|
-
descriptionListTermsWidths.map((width) => it(`renders the class name for the ‘${width}’ terms column width`, () => {
|
|
28
|
-
const { container } = render(_jsx(DescriptionList, { termsWidth: width }));
|
|
29
|
-
const component = container.querySelector(':only-child');
|
|
30
|
-
expect(component).toHaveClass(`ams-description-list--${width}`);
|
|
31
|
-
}));
|
|
32
|
-
it('supports ForwardRef in React', () => {
|
|
33
|
-
const ref = createRef();
|
|
34
|
-
const { container } = render(_jsx(DescriptionList, { ref: ref }));
|
|
35
|
-
const component = container.querySelector(':only-child');
|
|
36
|
-
expect(ref.current).toBe(component);
|
|
37
|
-
});
|
|
38
|
-
it('renders the class name for inverse color', () => {
|
|
39
|
-
const { container } = render(_jsx(DescriptionList, { color: "inverse" }));
|
|
40
|
-
const component = container.querySelector(':only-child');
|
|
41
|
-
expect(component).toHaveClass('ams-description-list--inverse');
|
|
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 { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { DescriptionList } from './DescriptionList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Description List Description', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(DescriptionList.Description, { children: "Test" }));
|
|
13
|
-
const component = screen.getByRole('definition');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(DescriptionList.Description, { children: "Test" }));
|
|
19
|
-
const component = screen.getByRole('definition');
|
|
20
|
-
expect(component).toHaveClass('ams-description-list__description');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(DescriptionList.Description, { className: "extra", children: "Test" }));
|
|
24
|
-
const component = screen.getByRole('definition');
|
|
25
|
-
expect(component).toHaveClass('ams-description-list__description extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
render(_jsx(DescriptionList.Description, { ref: ref, children: "Test" }));
|
|
30
|
-
const component = screen.getByRole('definition');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -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 { DescriptionList } from './DescriptionList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Description List Section', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(DescriptionList.Section, { children: "Test" }));
|
|
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(DescriptionList.Section, { children: "Test" }));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-description-list__section');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(DescriptionList.Section, { className: "extra", children: "Test" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-description-list__section extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(DescriptionList.Section, { ref: ref, children: "Test" }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -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, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { DescriptionList } from './DescriptionList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Description List Term', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(DescriptionList.Term, { children: "Test" }));
|
|
13
|
-
const component = screen.getByRole('term');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(DescriptionList.Term, { children: "Test" }));
|
|
19
|
-
const component = screen.getByRole('term');
|
|
20
|
-
expect(component).toHaveClass('ams-description-list__term');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(DescriptionList.Term, { className: "extra", children: "Test" }));
|
|
24
|
-
const component = screen.getByRole('term');
|
|
25
|
-
expect(component).toHaveClass('ams-description-list__term extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
render(_jsx(DescriptionList.Term, { ref: ref, children: "Test" }));
|
|
30
|
-
const component = screen.getByRole('term');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,82 +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 { Dialog } from './Dialog';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Dialog', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(Dialog, { heading: "Test heading", open: true }));
|
|
13
|
-
const component = screen.getByRole('dialog');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(Dialog, { heading: "Test heading" }));
|
|
19
|
-
const component = screen.getByRole('dialog', { hidden: true });
|
|
20
|
-
expect(component).toHaveClass('ams-dialog');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(Dialog, { className: "extra", heading: "Test heading" }));
|
|
24
|
-
const component = screen.getByRole('dialog', { hidden: true });
|
|
25
|
-
expect(component).toHaveClass('ams-dialog extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
render(_jsx(Dialog, { heading: "Test heading", ref: ref }));
|
|
30
|
-
const component = screen.getByRole('dialog', { hidden: true });
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
it('is not visible when open attribute is not used', () => {
|
|
34
|
-
render(_jsx(Dialog, { heading: "Test heading" }));
|
|
35
|
-
const component = screen.getByRole('dialog', { hidden: true });
|
|
36
|
-
expect(component).toBeInTheDocument();
|
|
37
|
-
expect(component).not.toBeVisible();
|
|
38
|
-
});
|
|
39
|
-
it('renders a heading', () => {
|
|
40
|
-
render(_jsx(Dialog, { heading: "Test heading", open: true }));
|
|
41
|
-
const heading = screen.getByRole('heading', {
|
|
42
|
-
name: 'Test heading',
|
|
43
|
-
});
|
|
44
|
-
expect(heading).toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
it('renders children', () => {
|
|
47
|
-
const { getByText } = render(_jsx(Dialog, { heading: "Test heading", children: "Test content" }));
|
|
48
|
-
expect(getByText('Test content')).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
it('renders footer when provided', () => {
|
|
51
|
-
render(_jsx(Dialog, { footer: _jsx("button", { children: "Click Me" }), heading: "Test heading", open: true }));
|
|
52
|
-
const footer = screen.getByRole('contentinfo');
|
|
53
|
-
const button = screen.getByRole('button', {
|
|
54
|
-
name: 'Click Me',
|
|
55
|
-
});
|
|
56
|
-
expect(footer).toBeInTheDocument();
|
|
57
|
-
expect(button).toBeInTheDocument();
|
|
58
|
-
});
|
|
59
|
-
it('does not render footer when not provided', () => {
|
|
60
|
-
const { container } = render(_jsx(Dialog, { heading: "Test heading" }));
|
|
61
|
-
const component = container.querySelector('footer');
|
|
62
|
-
expect(component).not.toBeInTheDocument();
|
|
63
|
-
});
|
|
64
|
-
it('renders DialogClose button', () => {
|
|
65
|
-
render(_jsx(Dialog, { heading: "Test heading", open: true }));
|
|
66
|
-
const closeButton = screen.getByRole('button', { name: 'Sluiten' });
|
|
67
|
-
expect(closeButton).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
it('renders a custom close label', () => {
|
|
70
|
-
render(_jsx(Dialog, { closeButtonLabel: "Close", heading: "Test heading", open: true }));
|
|
71
|
-
const closeButton = screen.getByRole('button', { name: 'Close' });
|
|
72
|
-
expect(closeButton).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
it.skip('can be closed with the Close button', () => {
|
|
75
|
-
// We currently can't test this because dialog isn't properly supported in jsdom
|
|
76
|
-
// https://github.com/jsdom/jsdom/issues/3294
|
|
77
|
-
});
|
|
78
|
-
it.skip('has no accessible content when it is closed', () => {
|
|
79
|
-
// We currently can't test this because dialog isn't properly supported in jsdom
|
|
80
|
-
// https://github.com/jsdom/jsdom/issues/3294
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,53 +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 { ErrorMessage } from './ErrorMessage';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Error message', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(ErrorMessage, {}));
|
|
13
|
-
const component = screen.getByRole('paragraph');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(ErrorMessage, {}));
|
|
19
|
-
const component = screen.getByRole('paragraph');
|
|
20
|
-
expect(component).toHaveClass('ams-error-message');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(ErrorMessage, { className: "extra" }));
|
|
24
|
-
const component = screen.getByRole('paragraph');
|
|
25
|
-
expect(component).toHaveClass('ams-error-message extra');
|
|
26
|
-
});
|
|
27
|
-
it('renders a Dutch prefix by default', () => {
|
|
28
|
-
render(_jsx(ErrorMessage, {}));
|
|
29
|
-
const component = screen.getByText('Invoerfout', { exact: false });
|
|
30
|
-
expect(component).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
it('renders a custom prefix', () => {
|
|
33
|
-
render(_jsx(ErrorMessage, { prefix: "Error" }));
|
|
34
|
-
const component = screen.getByText('Error', { exact: false });
|
|
35
|
-
expect(component).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
it('supports ForwardRef in React', () => {
|
|
38
|
-
const ref = createRef();
|
|
39
|
-
render(_jsx(ErrorMessage, { ref: ref }));
|
|
40
|
-
const component = screen.getByRole('paragraph');
|
|
41
|
-
expect(ref.current).toBe(component);
|
|
42
|
-
});
|
|
43
|
-
it('shows an icon', () => {
|
|
44
|
-
const { container } = render(_jsx(ErrorMessage, {}));
|
|
45
|
-
const iconWrapper = container.querySelector('.ams-icon');
|
|
46
|
-
const icon = container.querySelector('svg');
|
|
47
|
-
expect(iconWrapper).toBeInTheDocument();
|
|
48
|
-
expect(icon).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
// TODO: we can't currently test this, because we can't pass a class or anything to the SVG
|
|
51
|
-
// We plan on changing this, so we can test this in the future
|
|
52
|
-
it.skip('shows a custom icon', () => { });
|
|
53
|
-
});
|
package/dist/Field/Field.test.js
DELETED
|
@@ -1,38 +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 { Field } from './Field';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Field', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(Field, {}));
|
|
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(Field, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-field');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(Field, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-field extra');
|
|
26
|
-
});
|
|
27
|
-
it('renders with the error class', () => {
|
|
28
|
-
const { container } = render(_jsx(Field, { invalid: true }));
|
|
29
|
-
const component = container.querySelector(':only-child');
|
|
30
|
-
expect(component).toHaveClass('ams-field--invalid');
|
|
31
|
-
});
|
|
32
|
-
it('supports ForwardRef in React', () => {
|
|
33
|
-
const ref = createRef();
|
|
34
|
-
const { container } = render(_jsx(Field, { ref: ref }));
|
|
35
|
-
const component = container.querySelector(':only-child');
|
|
36
|
-
expect(ref.current).toBe(component);
|
|
37
|
-
});
|
|
38
|
-
});
|