@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
package/dist/Tabs/Tabs.test.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } 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 userEvent from '@testing-library/user-event';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { Tabs } from './Tabs';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
describe('Tabs', () => {
|
|
12
|
-
it('renders', () => {
|
|
13
|
-
const { container } = render(_jsx(Tabs, {}));
|
|
14
|
-
const component = container.querySelector(':only-child');
|
|
15
|
-
expect(component).toBeInTheDocument();
|
|
16
|
-
expect(component).toBeVisible();
|
|
17
|
-
});
|
|
18
|
-
it('renders a design system BEM class name', () => {
|
|
19
|
-
const { container } = render(_jsx(Tabs, {}));
|
|
20
|
-
const component = container.querySelector(':only-child');
|
|
21
|
-
expect(component).toHaveClass('ams-tabs');
|
|
22
|
-
});
|
|
23
|
-
it('renders an extra class name', () => {
|
|
24
|
-
const { container } = render(_jsx(Tabs, { className: "extra" }));
|
|
25
|
-
const component = container.querySelector(':only-child');
|
|
26
|
-
expect(component).toHaveClass('ams-tabs extra');
|
|
27
|
-
});
|
|
28
|
-
it('supports ForwardRef in React', () => {
|
|
29
|
-
const ref = createRef();
|
|
30
|
-
const { container } = render(_jsx(Tabs, { ref: ref }));
|
|
31
|
-
const component = container.querySelector(':only-child');
|
|
32
|
-
expect(ref.current).toBe(component);
|
|
33
|
-
});
|
|
34
|
-
it('supports children', () => {
|
|
35
|
-
render(_jsxs(Tabs, { children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }), _jsx(Tabs.Button, { "aria-controls": "two", children: "Tab 2" })] }), _jsx(Tabs.Panel, { id: "one", children: "Content 1" }), _jsx(Tabs.Panel, { id: "two", children: "Content 2" })] }));
|
|
36
|
-
expect(screen.getByRole('tablist')).toBeInTheDocument();
|
|
37
|
-
expect(screen.getByRole('tab', { selected: true })).toBeInTheDocument();
|
|
38
|
-
expect(screen.getByRole('tabpanel')).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
it('should select a tab when clicked', async () => {
|
|
41
|
-
const user = userEvent.setup();
|
|
42
|
-
render(_jsxs(Tabs, { children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }), _jsx(Tabs.Button, { "aria-controls": "two", children: "Tab 2" })] }), _jsx(Tabs.Panel, { id: "one", children: "Content 1" }), _jsx(Tabs.Panel, { id: "two", children: "Content 2" })] }));
|
|
43
|
-
const tabOne = screen.getByRole('tab', { name: 'Tab 1' });
|
|
44
|
-
const tabTwo = screen.getByRole('tab', { name: 'Tab 2' });
|
|
45
|
-
expect(tabOne).toHaveAttribute('aria-selected', 'true');
|
|
46
|
-
expect(tabOne).toHaveAttribute('tabindex', '0');
|
|
47
|
-
expect(tabTwo).toHaveAttribute('aria-selected', 'false');
|
|
48
|
-
expect(tabTwo).toHaveAttribute('tabindex', '-1');
|
|
49
|
-
expect(screen.getByRole('tabpanel')).toHaveTextContent('Content 1');
|
|
50
|
-
if (tabTwo) {
|
|
51
|
-
await user.click(tabTwo);
|
|
52
|
-
}
|
|
53
|
-
expect(tabOne).toHaveAttribute('aria-selected', 'false');
|
|
54
|
-
expect(tabOne).toHaveAttribute('tabindex', '-1');
|
|
55
|
-
expect(tabTwo).toHaveAttribute('aria-selected', 'true');
|
|
56
|
-
expect(tabTwo).toHaveAttribute('tabindex', '0');
|
|
57
|
-
expect(screen.getByRole('tabpanel')).toHaveTextContent('Content 2');
|
|
58
|
-
});
|
|
59
|
-
it('calls onTabChange with the newly activated tab', async () => {
|
|
60
|
-
const user = userEvent.setup();
|
|
61
|
-
const onTabChange = jest.fn();
|
|
62
|
-
render(_jsx(Tabs, { onTabChange: onTabChange, children: _jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }) }) }));
|
|
63
|
-
const button = screen.getByRole('tab', { name: 'Tab 1' });
|
|
64
|
-
await user.click(button);
|
|
65
|
-
expect(onTabChange).toHaveBeenCalledWith('one');
|
|
66
|
-
});
|
|
67
|
-
it('should be able to set the initially active tab', () => {
|
|
68
|
-
render(_jsxs(Tabs, { activeTab: "three", children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }), _jsx(Tabs.Button, { "aria-controls": "two", children: "Tab 2" }), _jsx(Tabs.Button, { "aria-controls": "three", children: "Tab 3" }), _jsx(Tabs.Button, { "aria-controls": "four", children: "Tab 4" })] }), _jsx(Tabs.Panel, { id: "one", children: "Content 1" }), _jsx(Tabs.Panel, { id: "two", children: "Content 2" }), _jsx(Tabs.Panel, { id: "three", children: "Content 3" }), _jsx(Tabs.Panel, { id: "four", children: "Content 4" })] }));
|
|
69
|
-
const tabOne = screen.getByRole('tab', { name: 'Tab 1' });
|
|
70
|
-
const tabThree = screen.getByRole('tab', { name: 'Tab 3' });
|
|
71
|
-
expect(tabOne).toHaveAttribute('aria-selected', 'false');
|
|
72
|
-
expect(tabOne).toHaveAttribute('tabindex', '-1');
|
|
73
|
-
expect(tabThree).toHaveAttribute('aria-selected', 'true');
|
|
74
|
-
expect(tabThree).toHaveAttribute('tabindex', '0');
|
|
75
|
-
expect(screen.getByRole('tabpanel')).toHaveTextContent('Content 3');
|
|
76
|
-
});
|
|
77
|
-
it('should set the first tab as the initially active tab when the supplied active tab does not exist', async () => {
|
|
78
|
-
// Disable console.warn for this test, to prevent it from cluttering the test output
|
|
79
|
-
jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
80
|
-
render(_jsxs(Tabs, { activeTab: "unknown", children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }), _jsx(Tabs.Button, { "aria-controls": "two", children: "Tab 2" }), _jsx(Tabs.Button, { "aria-controls": "three", children: "Tab 3" }), _jsx(Tabs.Button, { "aria-controls": "four", children: "Tab 4" })] }), _jsx(Tabs.Panel, { id: "one", children: "Content 1" }), _jsx(Tabs.Panel, { id: "two", children: "Content 2" }), _jsx(Tabs.Panel, { id: "three", children: "Content 3" }), _jsx(Tabs.Panel, { id: "four", children: "Content 4" })] }));
|
|
81
|
-
const firstTab = screen.getByRole('tab', { name: 'Tab 1' });
|
|
82
|
-
const lastTab = screen.getByRole('tab', { name: 'Tab 4' });
|
|
83
|
-
expect(firstTab).toHaveAttribute('aria-selected', 'true');
|
|
84
|
-
expect(firstTab).toHaveAttribute('tabindex', '0');
|
|
85
|
-
expect(lastTab).toHaveAttribute('aria-selected', 'false');
|
|
86
|
-
expect(lastTab).toHaveAttribute('tabindex', '-1');
|
|
87
|
-
expect(screen.getByRole('tabpanel')).toHaveTextContent('Content 1');
|
|
88
|
-
});
|
|
89
|
-
it('sets focus on Tabs buttons when using arrow keys', async () => {
|
|
90
|
-
const user = userEvent.setup();
|
|
91
|
-
render(_jsxs(Tabs, { children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Button, { "aria-controls": "one", children: "Tab 1" }), _jsx(Tabs.Button, { "aria-controls": "two", children: "Tab 2" }), _jsx(Tabs.Button, { "aria-controls": "three", children: "Tab 3" })] }), _jsx(Tabs.Panel, { id: "one" }), _jsx(Tabs.Panel, { id: "two" }), _jsx(Tabs.Panel, { id: "three" })] }));
|
|
92
|
-
const firstButton = screen.getByRole('tab', { name: 'Tab 1' });
|
|
93
|
-
const thirdButton = screen.getByRole('tab', { name: 'Tab 3' });
|
|
94
|
-
await user.click(firstButton);
|
|
95
|
-
expect(firstButton).toHaveFocus();
|
|
96
|
-
// Click the right arrow key twice
|
|
97
|
-
await user.keyboard('{ArrowRight}');
|
|
98
|
-
await user.keyboard('{ArrowRight}');
|
|
99
|
-
expect(thirdButton).toHaveFocus();
|
|
100
|
-
expect(firstButton).not.toHaveFocus();
|
|
101
|
-
await user.keyboard('{ArrowRight}');
|
|
102
|
-
expect(firstButton).toHaveFocus();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,57 +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 userEvent from '@testing-library/user-event';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { TabsButton } from './TabsButton';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
import { TabsContext } from './TabsContext';
|
|
12
|
-
describe('Tabs button', () => {
|
|
13
|
-
it('renders', () => {
|
|
14
|
-
render(_jsx(TabsButton, { "aria-controls": "one" }));
|
|
15
|
-
const component = screen.getByRole('tab');
|
|
16
|
-
expect(component).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
it('renders a design system BEM class name', () => {
|
|
19
|
-
render(_jsx(TabsButton, { "aria-controls": "one" }));
|
|
20
|
-
const component = screen.getByRole('tab');
|
|
21
|
-
expect(component).toHaveClass('ams-tabs__button');
|
|
22
|
-
});
|
|
23
|
-
it('renders an extra class name', () => {
|
|
24
|
-
render(_jsx(TabsButton, { "aria-controls": "one", className: "extra" }));
|
|
25
|
-
const component = screen.getByRole('tab');
|
|
26
|
-
expect(component).toHaveClass('ams-tabs__button extra');
|
|
27
|
-
});
|
|
28
|
-
it('renders a label', () => {
|
|
29
|
-
render(_jsx(TabsButton, { "aria-controls": "one", children: "Label" }));
|
|
30
|
-
const component = screen.getByRole('tab', { name: 'Label' });
|
|
31
|
-
expect(component).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
it('renders the correct id based on the tabs prop', () => {
|
|
34
|
-
const { container } = render(_jsx(TabsButton, { "aria-controls": "one" }));
|
|
35
|
-
const component = container.querySelector('#button-one');
|
|
36
|
-
expect(component).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
it('should associate the button with the correct tab', () => {
|
|
39
|
-
render(_jsx(TabsButton, { "aria-controls": "one" }));
|
|
40
|
-
const component = screen.getByRole('tab');
|
|
41
|
-
expect(component).toHaveAttribute('aria-controls', 'one');
|
|
42
|
-
});
|
|
43
|
-
it('does not call updateTab if event.preventDefault is invoked', async () => {
|
|
44
|
-
const user = userEvent.setup();
|
|
45
|
-
const mockUpdateTab = jest.fn();
|
|
46
|
-
render(_jsx(TabsContext.Provider, { value: { updateTab: mockUpdateTab }, children: _jsx(TabsButton, { "aria-controls": "one", onClick: (event) => event.preventDefault(), children: "Label" }) }));
|
|
47
|
-
const button = screen.getByRole('tab', { name: 'Label' });
|
|
48
|
-
await user.click(button);
|
|
49
|
-
expect(mockUpdateTab).not.toHaveBeenCalled();
|
|
50
|
-
});
|
|
51
|
-
it('supports ForwardRef in React', () => {
|
|
52
|
-
const ref = createRef();
|
|
53
|
-
render(_jsx(TabsButton, { "aria-controls": "one", ref: ref }));
|
|
54
|
-
const component = screen.getByRole('tab');
|
|
55
|
-
expect(ref.current).toBe(component);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,32 +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 { TabsList } from './TabsList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Tabs list', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(TabsList, {}));
|
|
13
|
-
const component = screen.getByRole('tablist');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
it('renders a design system BEM class name', () => {
|
|
17
|
-
render(_jsx(TabsList, {}));
|
|
18
|
-
const component = screen.getByRole('tablist');
|
|
19
|
-
expect(component).toHaveClass('ams-tabs__list');
|
|
20
|
-
});
|
|
21
|
-
it('renders an extra class name', () => {
|
|
22
|
-
render(_jsx(TabsList, { className: "extra" }));
|
|
23
|
-
const component = screen.getByRole('tablist');
|
|
24
|
-
expect(component).toHaveClass('ams-tabs__list extra');
|
|
25
|
-
});
|
|
26
|
-
it('supports ForwardRef in React', () => {
|
|
27
|
-
const ref = createRef();
|
|
28
|
-
render(_jsx(TabsList, { ref: ref }));
|
|
29
|
-
const component = screen.getByRole('tablist');
|
|
30
|
-
expect(ref.current).toBe(component);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } 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 { Tabs } from './Tabs';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Tabs Panel', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { id: "one" })] }));
|
|
13
|
-
const component = screen.getByRole('tabpanel');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
it('renders a design system BEM class name', () => {
|
|
17
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { id: "one" })] }));
|
|
18
|
-
const component = screen.getByRole('tabpanel');
|
|
19
|
-
expect(component).toHaveClass('ams-tabs__panel');
|
|
20
|
-
});
|
|
21
|
-
it('renders an extra class name', () => {
|
|
22
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { className: "extra", id: "one" })] }));
|
|
23
|
-
const component = screen.getByRole('tabpanel');
|
|
24
|
-
expect(component).toHaveClass('ams-tabs__panel extra');
|
|
25
|
-
});
|
|
26
|
-
it('renders the correct id based on the tabs prop', () => {
|
|
27
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { id: "one" })] }));
|
|
28
|
-
const component = screen.getByRole('tabpanel');
|
|
29
|
-
expect(component).toHaveAttribute('id', 'one');
|
|
30
|
-
});
|
|
31
|
-
it('should associate the tab with the correct button', () => {
|
|
32
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { id: "one" })] }));
|
|
33
|
-
const component = screen.getByRole('tabpanel');
|
|
34
|
-
expect(component).toHaveAttribute('aria-labelledby', 'button-one');
|
|
35
|
-
});
|
|
36
|
-
it('supports ForwardRef in React', () => {
|
|
37
|
-
const ref = createRef();
|
|
38
|
-
render(_jsxs(Tabs, { children: [_jsx(Tabs.List, { children: _jsx(Tabs.Button, { "aria-controls": "one" }) }), _jsx(Tabs.Panel, { id: "one", ref: ref })] }));
|
|
39
|
-
const component = screen.getByRole('tabpanel');
|
|
40
|
-
expect(ref.current).toBe(component);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,105 +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 userEvent from '@testing-library/user-event';
|
|
8
|
-
import { createRef, useState } from 'react';
|
|
9
|
-
import { TextArea } from './TextArea';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
describe('Text area', () => {
|
|
12
|
-
it('renders', () => {
|
|
13
|
-
render(_jsx(TextArea, {}));
|
|
14
|
-
const component = screen.getByRole('textbox');
|
|
15
|
-
expect(component).toBeInTheDocument();
|
|
16
|
-
expect(component).toBeVisible();
|
|
17
|
-
});
|
|
18
|
-
it('renders a design system BEM class name', () => {
|
|
19
|
-
render(_jsx(TextArea, {}));
|
|
20
|
-
const component = screen.getByRole('textbox');
|
|
21
|
-
expect(component).toHaveClass('ams-text-area');
|
|
22
|
-
});
|
|
23
|
-
it('renders an extra class name', () => {
|
|
24
|
-
render(_jsx(TextArea, { className: "extra" }));
|
|
25
|
-
const component = screen.getByRole('textbox');
|
|
26
|
-
expect(component).toHaveClass('ams-text-area extra');
|
|
27
|
-
});
|
|
28
|
-
it('renders a textarea with horizontal resize', () => {
|
|
29
|
-
render(_jsx(TextArea, { resize: "horizontal" }));
|
|
30
|
-
const component = screen.getByRole('textbox');
|
|
31
|
-
expect(component).toHaveClass('ams-text-area ams-text-area--resize-horizontal');
|
|
32
|
-
});
|
|
33
|
-
it('renders a textarea with vertical resize', () => {
|
|
34
|
-
render(_jsx(TextArea, { resize: "vertical" }));
|
|
35
|
-
const component = screen.getByRole('textbox');
|
|
36
|
-
expect(component).toHaveClass('ams-text-area ams-text-area--resize-vertical');
|
|
37
|
-
});
|
|
38
|
-
it('renders a textarea with no resize', () => {
|
|
39
|
-
render(_jsx(TextArea, { resize: "none" }));
|
|
40
|
-
const component = screen.getByRole('textbox');
|
|
41
|
-
expect(component).toHaveClass('ams-text-area ams-text-area--resize-none');
|
|
42
|
-
});
|
|
43
|
-
it('renders a textarea with cols class when cols prop is provided', () => {
|
|
44
|
-
render(_jsx(TextArea, { cols: 10 }));
|
|
45
|
-
const component = screen.getByRole('textbox');
|
|
46
|
-
expect(component).toHaveClass('ams-text-area ams-text-area--cols');
|
|
47
|
-
});
|
|
48
|
-
it('can be controlled', async () => {
|
|
49
|
-
function ControlledComponent() {
|
|
50
|
-
const [value, setValue] = useState('Hello');
|
|
51
|
-
return _jsx(TextArea, { onChange: (e) => setValue(e.target.value), value: value });
|
|
52
|
-
}
|
|
53
|
-
render(_jsx(ControlledComponent, {}));
|
|
54
|
-
const componentText = screen.getByDisplayValue('Hello');
|
|
55
|
-
expect(componentText).toBeInTheDocument();
|
|
56
|
-
const component = screen.getByRole('textbox');
|
|
57
|
-
if (component) {
|
|
58
|
-
await userEvent.type(component, ', World!');
|
|
59
|
-
}
|
|
60
|
-
const newComponentText = screen.getByDisplayValue('Hello, World!');
|
|
61
|
-
expect(newComponentText).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
it('should not update the value when disabled', async () => {
|
|
64
|
-
render(_jsx(TextArea, { defaultValue: "Hello", disabled: true }));
|
|
65
|
-
const component = screen.getByRole('textbox');
|
|
66
|
-
if (component) {
|
|
67
|
-
await userEvent.type(component, ', World!');
|
|
68
|
-
}
|
|
69
|
-
expect(component).toHaveValue('Hello');
|
|
70
|
-
});
|
|
71
|
-
it('supports ForwardRef in React', () => {
|
|
72
|
-
const ref = createRef();
|
|
73
|
-
render(_jsx(TextArea, { ref: ref }));
|
|
74
|
-
const component = screen.getByRole('textbox');
|
|
75
|
-
expect(ref.current).toBe(component);
|
|
76
|
-
});
|
|
77
|
-
it('renders bidirectional by default using `dir="auto"`', () => {
|
|
78
|
-
render(_jsx(TextArea, {}));
|
|
79
|
-
const component = screen.getByRole('textbox');
|
|
80
|
-
expect(component).toHaveAttribute('dir', 'auto');
|
|
81
|
-
});
|
|
82
|
-
it('renders left-to-right by using `dir="ltr"`', () => {
|
|
83
|
-
render(_jsx(TextArea, { dir: "ltr" }));
|
|
84
|
-
const component = screen.getByRole('textbox');
|
|
85
|
-
expect(component).toHaveAttribute('dir', 'ltr');
|
|
86
|
-
});
|
|
87
|
-
describe('Invalid state', () => {
|
|
88
|
-
it('is not invalid by default', () => {
|
|
89
|
-
render(_jsx(TextArea, {}));
|
|
90
|
-
const component = screen.getByRole('textbox');
|
|
91
|
-
expect(component).not.toBeInvalid();
|
|
92
|
-
});
|
|
93
|
-
it('can have an invalid state', () => {
|
|
94
|
-
render(_jsx(TextArea, { invalid: true }));
|
|
95
|
-
const component = screen.getByRole('textbox');
|
|
96
|
-
expect(component).toHaveAttribute('aria-invalid');
|
|
97
|
-
expect(component).toBeInvalid();
|
|
98
|
-
});
|
|
99
|
-
it('omits non-essential invalid attributes when not invalid', () => {
|
|
100
|
-
render(_jsx(TextArea, { invalid: false }));
|
|
101
|
-
const component = screen.getByRole('textbox');
|
|
102
|
-
expect(component).not.toHaveAttribute('aria-invalid');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,92 +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 userEvent from '@testing-library/user-event';
|
|
8
|
-
import { createRef, useState } from 'react';
|
|
9
|
-
import { TextInput, textInputTypes } from './TextInput';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
describe('Text input', () => {
|
|
12
|
-
it('renders', () => {
|
|
13
|
-
render(_jsx(TextInput, {}));
|
|
14
|
-
const component = screen.getByRole('textbox');
|
|
15
|
-
expect(component).toBeInTheDocument();
|
|
16
|
-
expect(component).toBeVisible();
|
|
17
|
-
});
|
|
18
|
-
it('renders a design system BEM class name', () => {
|
|
19
|
-
render(_jsx(TextInput, {}));
|
|
20
|
-
const component = screen.getByRole('textbox');
|
|
21
|
-
expect(component).toHaveClass('ams-text-input');
|
|
22
|
-
});
|
|
23
|
-
it('renders an extra class name', () => {
|
|
24
|
-
render(_jsx(TextInput, { className: "extra" }));
|
|
25
|
-
const component = screen.getByRole('textbox');
|
|
26
|
-
expect(component).toHaveClass('ams-text-input extra');
|
|
27
|
-
});
|
|
28
|
-
it('should be working in a controlled state', async () => {
|
|
29
|
-
function ControlledComponent() {
|
|
30
|
-
const [value, setValue] = useState('Hello');
|
|
31
|
-
return _jsx(TextInput, { onChange: (e) => setValue(e.target.value), value: value });
|
|
32
|
-
}
|
|
33
|
-
render(_jsx(ControlledComponent, {}));
|
|
34
|
-
const componentText = screen.getByDisplayValue('Hello');
|
|
35
|
-
expect(componentText).toBeInTheDocument();
|
|
36
|
-
const component = screen.getByRole('textbox');
|
|
37
|
-
if (component) {
|
|
38
|
-
await userEvent.type(component, ', World!');
|
|
39
|
-
}
|
|
40
|
-
const newComponentText = screen.getByDisplayValue('Hello, World!');
|
|
41
|
-
expect(newComponentText).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
it('should not update the value when disabled', async () => {
|
|
44
|
-
render(_jsx(TextInput, { defaultValue: "Hello", disabled: true }));
|
|
45
|
-
const component = screen.getByRole('textbox');
|
|
46
|
-
if (component) {
|
|
47
|
-
await userEvent.type(component, ', World!');
|
|
48
|
-
}
|
|
49
|
-
expect(component).toHaveValue('Hello');
|
|
50
|
-
});
|
|
51
|
-
it('supports ForwardRef in React', () => {
|
|
52
|
-
const ref = createRef();
|
|
53
|
-
render(_jsx(TextInput, { ref: ref }));
|
|
54
|
-
const component = screen.getByRole('textbox');
|
|
55
|
-
expect(ref.current).toBe(component);
|
|
56
|
-
});
|
|
57
|
-
it('renders bidirectional by default using `dir="auto"`', () => {
|
|
58
|
-
render(_jsx(TextInput, {}));
|
|
59
|
-
const component = screen.getByRole('textbox');
|
|
60
|
-
expect(component).toHaveAttribute('dir', 'auto');
|
|
61
|
-
});
|
|
62
|
-
it('renders left-to-right by using `dir="ltr"`', () => {
|
|
63
|
-
render(_jsx(TextInput, { dir: "ltr" }));
|
|
64
|
-
const component = screen.getByRole('textbox');
|
|
65
|
-
expect(component).toHaveAttribute('dir', 'ltr');
|
|
66
|
-
});
|
|
67
|
-
describe('Invalid state', () => {
|
|
68
|
-
it('is not invalid by default', () => {
|
|
69
|
-
render(_jsx(TextInput, {}));
|
|
70
|
-
const component = screen.getByRole('textbox');
|
|
71
|
-
expect(component).not.toBeInvalid();
|
|
72
|
-
});
|
|
73
|
-
it('can have an invalid state', () => {
|
|
74
|
-
render(_jsx(TextInput, { invalid: true }));
|
|
75
|
-
const component = screen.getByRole('textbox');
|
|
76
|
-
expect(component).toHaveAttribute('aria-invalid');
|
|
77
|
-
expect(component).toBeInvalid();
|
|
78
|
-
});
|
|
79
|
-
it('omits non-essential invalid attributes when not invalid', () => {
|
|
80
|
-
render(_jsx(TextInput, { invalid: false }));
|
|
81
|
-
const component = screen.getByRole('textbox');
|
|
82
|
-
expect(component).not.toHaveAttribute('aria-invalid');
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('Type', () => {
|
|
86
|
-
textInputTypes.map((type) => it(`sets the ‘${type}’ type`, () => {
|
|
87
|
-
render(_jsx(TextInput, { type: type }));
|
|
88
|
-
const component = screen.getByRole('textbox');
|
|
89
|
-
expect(component).toHaveAttribute('type', type);
|
|
90
|
-
}));
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,51 +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 { TimeInput } from './TimeInput';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Time input', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(TimeInput, {}));
|
|
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(TimeInput, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-time-input');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(TimeInput, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-time-input extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(TimeInput, { 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(TimeInput, {}));
|
|
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(TimeInput, { 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(TimeInput, { invalid: false }));
|
|
47
|
-
const component = container.querySelector(':only-child');
|
|
48
|
-
expect(component).not.toHaveAttribute('aria-invalid');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -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 { UnorderedList } from './UnorderedList';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Unordered list', () => {
|
|
11
|
-
it('renders an HTML ul element', () => {
|
|
12
|
-
const { container } = render(_jsx(UnorderedList, {}));
|
|
13
|
-
const list = container.querySelector('ul:only-child');
|
|
14
|
-
expect(list).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
it('renders a design system BEM class name', () => {
|
|
17
|
-
render(_jsx(UnorderedList, {}));
|
|
18
|
-
const component = screen.getByRole('list');
|
|
19
|
-
expect(component).toHaveClass('ams-unordered-list');
|
|
20
|
-
});
|
|
21
|
-
it('renders a no markers class', () => {
|
|
22
|
-
render(_jsx(UnorderedList, { markers: false }));
|
|
23
|
-
const component = screen.getByRole('list');
|
|
24
|
-
expect(component).toHaveClass('ams-unordered-list--no-markers');
|
|
25
|
-
});
|
|
26
|
-
it('renders the class name for inverse color', () => {
|
|
27
|
-
render(_jsx(UnorderedList, { color: "inverse" }));
|
|
28
|
-
const component = screen.getByRole('list');
|
|
29
|
-
expect(component).toHaveClass('ams-unordered-list--inverse');
|
|
30
|
-
});
|
|
31
|
-
it('renders an extra class name', () => {
|
|
32
|
-
render(_jsx(UnorderedList, { className: "extra" }));
|
|
33
|
-
const component = screen.getByRole('list');
|
|
34
|
-
expect(component).toHaveClass('ams-unordered-list extra');
|
|
35
|
-
});
|
|
36
|
-
it('renders its subcomponent', () => {
|
|
37
|
-
const listItems = ['Item 1', 'Item 2', 'Item 3'];
|
|
38
|
-
const { container } = render(_jsx(UnorderedList, { children: listItems.map((item) => (_jsx(UnorderedList.Item, { children: item }, item))) }));
|
|
39
|
-
const list = screen.getByRole('list');
|
|
40
|
-
const items = container.querySelectorAll('.ams-unordered-list__item');
|
|
41
|
-
expect(list).toBeInTheDocument();
|
|
42
|
-
expect(items.length).toBe(3);
|
|
43
|
-
});
|
|
44
|
-
it('renders the small size class', () => {
|
|
45
|
-
render(_jsx(UnorderedList, { size: "small" }));
|
|
46
|
-
const component = screen.getByRole('list');
|
|
47
|
-
expect(component).toHaveClass('ams-unordered-list--small');
|
|
48
|
-
});
|
|
49
|
-
it('supports ForwardRef in React', () => {
|
|
50
|
-
const ref = createRef();
|
|
51
|
-
render(_jsx(UnorderedList, { ref: ref }));
|
|
52
|
-
const component = screen.getByRole('list');
|
|
53
|
-
expect(ref.current).toBe(component);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,32 +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 { UnorderedListItem } from './UnorderedListItem';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Ordered list item', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(UnorderedListItem, {}));
|
|
13
|
-
const component = screen.getByRole('listitem');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
it('renders a design system BEM class name', () => {
|
|
17
|
-
render(_jsx(UnorderedListItem, {}));
|
|
18
|
-
const component = screen.getByRole('listitem');
|
|
19
|
-
expect(component).toHaveClass('ams-unordered-list__item');
|
|
20
|
-
});
|
|
21
|
-
it('renders an extra class name', () => {
|
|
22
|
-
render(_jsx(UnorderedListItem, { className: "extra" }));
|
|
23
|
-
const component = screen.getByRole('listitem');
|
|
24
|
-
expect(component).toHaveClass('ams-unordered-list__item extra');
|
|
25
|
-
});
|
|
26
|
-
it('supports ForwardRef in React', () => {
|
|
27
|
-
const ref = createRef();
|
|
28
|
-
render(_jsx(UnorderedListItem, { ref: ref }));
|
|
29
|
-
const component = screen.getByRole('listitem');
|
|
30
|
-
expect(ref.current).toBe(component);
|
|
31
|
-
});
|
|
32
|
-
});
|