@ilo-org/react 0.12.0 → 0.14.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/.storybook/main.ts +41 -0
- package/.storybook/manager-head.html +92 -0
- package/.storybook/manager.ts +6 -0
- package/.storybook/preview-head.html +5 -0
- package/.storybook/preview.tsx +81 -0
- package/.storybook/styles.scss +25 -0
- package/.storybook/theme.ts +46 -0
- package/.turbo/turbo-build:lib.log +15 -0
- package/CHANGELOG.md +43 -0
- package/lib/cjs/components/Cards/CardGroup/CardGroup.js +41 -0
- package/lib/cjs/components/Cards/CardGroup/index.js +796 -0
- package/lib/cjs/components/Cards/DataCard/DataCard.js +27 -0
- package/lib/cjs/components/Cards/DataCard/index.js +73 -19
- package/lib/cjs/components/Cards/DetailCard/DetailCard.js +20 -0
- package/lib/cjs/components/Cards/DetailCard/index.js +17 -12
- package/lib/cjs/components/Cards/FactlistCard/FactListCard.js +22 -0
- package/lib/cjs/components/Cards/FactlistCard/index.js +16 -15
- package/lib/cjs/components/Cards/FeatureCard/FeatureCard.js +24 -0
- package/lib/cjs/components/Cards/FeatureCard/index.js +31 -16
- package/lib/cjs/components/Cards/MultilinkCard/MultiLinkCard.js +24 -0
- package/lib/cjs/components/Cards/MultilinkCard/index.js +35 -16
- package/lib/cjs/components/Cards/PromoCard/PromoCard.js +23 -0
- package/lib/cjs/components/Cards/PromoCard/index.js +18 -15
- package/lib/cjs/components/Cards/StatCard/StatCard.js +21 -0
- package/lib/cjs/components/Cards/StatCard/index.js +15 -13
- package/lib/cjs/components/Cards/TextCard/TextCard.js +23 -0
- package/lib/cjs/components/Cards/TextCard/index.js +22 -17
- package/lib/cjs/components/Footer/Footer.js +1 -1
- package/lib/cjs/components/List/List.js +9 -11
- package/lib/cjs/components/List/ListItem.js +4 -7
- package/lib/cjs/components/List/index.js +1 -2
- package/lib/cjs/components/Navigation/Navigation.js +3 -3
- package/lib/cjs/components/Pagination/Pagination.js +1 -1
- package/lib/cjs/components/index.js +10 -13
- package/lib/cjs/index.js +10 -13
- package/lib/esm/components/Cards/CardGroup/CardGroup.js +39 -0
- package/lib/esm/components/Cards/CardGroup/index.js +793 -0
- package/lib/esm/components/Cards/DataCard/DataCard.js +25 -0
- package/lib/esm/components/Cards/DataCard/index.js +72 -19
- package/lib/esm/components/Cards/DetailCard/DetailCard.js +18 -0
- package/lib/esm/components/Cards/DetailCard/index.js +16 -12
- package/lib/esm/components/Cards/FactlistCard/FactListCard.js +20 -0
- package/lib/esm/components/Cards/FactlistCard/index.js +15 -15
- package/lib/esm/components/Cards/FeatureCard/FeatureCard.js +22 -0
- package/lib/esm/components/Cards/FeatureCard/index.js +30 -16
- package/lib/esm/components/Cards/MultilinkCard/MultiLinkCard.js +22 -0
- package/lib/esm/components/Cards/MultilinkCard/index.js +34 -16
- package/lib/esm/components/Cards/PromoCard/PromoCard.js +21 -0
- package/lib/esm/components/Cards/PromoCard/index.js +17 -15
- package/lib/esm/components/Cards/StatCard/StatCard.js +19 -0
- package/lib/esm/components/Cards/StatCard/index.js +14 -13
- package/lib/esm/components/Cards/TextCard/TextCard.js +21 -0
- package/lib/esm/components/Cards/TextCard/index.js +21 -17
- package/lib/esm/components/Footer/Footer.js +1 -1
- package/lib/esm/components/List/List.js +10 -12
- package/lib/esm/components/List/ListItem.js +4 -7
- package/lib/esm/components/List/index.js +1 -2
- package/lib/esm/components/Navigation/Navigation.js +3 -3
- package/lib/esm/components/Pagination/Pagination.js +1 -1
- package/lib/esm/components/index.js +9 -11
- package/lib/esm/index.js +9 -11
- package/lib/types/react/src/components/Cards/CardGroup/CardGroup.args.d.ts +13 -0
- package/lib/types/react/src/components/Cards/CardGroup/CardGroup.props.d.ts +58 -0
- package/lib/types/react/src/components/Cards/CardGroup/index.d.ts +3 -0
- package/lib/types/react/src/components/Cards/DataCard/DataCard.args.d.ts +2 -0
- package/lib/types/react/src/components/Cards/DataCard/DataCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/DataCard/DataCard.props.d.ts +50 -0
- package/lib/types/react/src/components/Cards/DataCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/DetailCard/DetailCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/DetailCard/DetailCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/DetailCard/DetailCard.props.d.ts +35 -0
- package/lib/types/react/src/components/Cards/DetailCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/FactlistCard/FactListCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/FactlistCard/FactListCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/FactlistCard/FactListCard.props.d.ts +16 -0
- package/lib/types/react/src/components/Cards/FactlistCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/FeatureCard/FeatureCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/FeatureCard/FeatureCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/FeatureCard/FeatureCard.props.d.ts +31 -0
- package/lib/types/react/src/components/Cards/FeatureCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/MultilinkCard/MultiLinkCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/MultilinkCard/MultilinkCard.args.d.ts +2 -0
- package/lib/types/react/src/components/Cards/MultilinkCard/MultilinkCard.props.d.ts +25 -0
- package/lib/types/react/src/components/Cards/MultilinkCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/PromoCard/PromoCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/PromoCard/PromoCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/PromoCard/PromoCard.props.d.ts +30 -0
- package/lib/types/react/src/components/Cards/PromoCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/StatCard/StatCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/StatCard/StatCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/StatCard/StatCard.props.d.ts +18 -0
- package/lib/types/react/src/components/Cards/StatCard/index.d.ts +3 -4
- package/lib/types/react/src/components/Cards/TextCard/TextCard.args.d.ts +3 -0
- package/lib/types/react/src/components/Cards/TextCard/TextCard.d.ts +4 -0
- package/lib/types/react/src/components/Cards/TextCard/TextCard.props.d.ts +26 -0
- package/lib/types/react/src/components/Cards/TextCard/index.d.ts +3 -4
- package/lib/types/react/src/components/List/List.props.d.ts +2 -9
- package/lib/types/react/src/components/List/ListItem.props.d.ts +0 -6
- package/lib/types/react/src/components/index.d.ts +1 -1
- package/lib/types/react/src/types/index.d.ts +4 -2
- package/package.json +32 -12
- package/public/react.svg +8 -0
- package/rollup.config.mjs +2 -0
- package/src/__tests__/Accordion.test.tsx +16 -0
- package/src/__tests__/Button.test.tsx +60 -0
- package/src/__tests__/Callout.test.tsx +43 -0
- package/src/__tests__/ContextMenu.test.tsx +19 -0
- package/src/__tests__/Dropdown.test.tsx +38 -0
- package/src/__tests__/Heading.test.tsx +51 -0
- package/src/__tests__/Image.test.tsx +21 -0
- package/src/__tests__/LinkList.test.tsx +17 -0
- package/src/__tests__/List.test.tsx +25 -0
- package/src/__tests__/Loading.test.tsx +33 -0
- package/src/__tests__/Notification.test.tsx +39 -0
- package/src/__tests__/Pagination.test.tsx +58 -0
- package/src/__tests__/Profile.test.tsx +48 -0
- package/src/__tests__/ReadMore.test.tsx +43 -0
- package/src/__tests__/RichText.test.tsx +16 -0
- package/src/__tests__/SearchField.test.tsx +35 -0
- package/src/__tests__/TableOfContents.test.tsx +12 -0
- package/src/__tests__/Tag.test.tsx +10 -0
- package/src/components/Cards/{CardGroup.args.ts → CardGroup/CardGroup.args.ts} +299 -437
- package/src/components/Cards/CardGroup/CardGroup.props.ts +78 -0
- package/src/components/Cards/CardGroup/CardGroup.tsx +54 -0
- package/src/components/Cards/CardGroup/index.tsx +3 -0
- package/src/components/Cards/DataCard/DataCard.args.ts +69 -0
- package/src/components/Cards/DataCard/DataCard.props.ts +60 -0
- package/src/components/Cards/DataCard/DataCard.tsx +107 -0
- package/src/components/Cards/DataCard/index.tsx +3 -107
- package/src/components/Cards/DetailCard/DetailCard.args.ts +17 -0
- package/src/components/Cards/DetailCard/DetailCard.props.ts +43 -0
- package/src/components/Cards/DetailCard/DetailCard.tsx +62 -0
- package/src/components/Cards/DetailCard/index.tsx +3 -62
- package/src/components/Cards/FactlistCard/FactListCard.args.ts +14 -0
- package/src/components/Cards/FactlistCard/FactListCard.props.ts +19 -0
- package/src/components/Cards/FactlistCard/FactListCard.tsx +42 -0
- package/src/components/Cards/FactlistCard/index.tsx +3 -42
- package/src/components/Cards/FeatureCard/FeatureCard.args.ts +30 -0
- package/src/components/Cards/FeatureCard/FeatureCard.props.ts +38 -0
- package/src/components/Cards/FeatureCard/FeatureCard.tsx +69 -0
- package/src/components/Cards/FeatureCard/index.tsx +3 -69
- package/src/components/Cards/MultilinkCard/MultiLinkCard.tsx +76 -0
- package/src/components/Cards/MultilinkCard/MultilinkCard.args.ts +33 -0
- package/src/components/Cards/MultilinkCard/MultilinkCard.props.ts +30 -0
- package/src/components/Cards/MultilinkCard/index.tsx +3 -76
- package/src/components/Cards/PromoCard/PromoCard.args.ts +19 -0
- package/src/components/Cards/PromoCard/PromoCard.props.ts +36 -0
- package/src/components/Cards/PromoCard/PromoCard.tsx +60 -0
- package/src/components/Cards/PromoCard/index.tsx +3 -60
- package/src/components/Cards/StatCard/StatCard.args.ts +14 -0
- package/src/components/Cards/StatCard/StatCard.props.ts +21 -0
- package/src/components/Cards/StatCard/StatCard.tsx +36 -0
- package/src/components/Cards/StatCard/index.tsx +3 -36
- package/src/components/Cards/TextCard/TextCard.args.ts +21 -0
- package/src/components/Cards/TextCard/TextCard.props.ts +32 -0
- package/src/components/Cards/TextCard/TextCard.tsx +62 -0
- package/src/components/Cards/TextCard/index.tsx +3 -63
- package/src/components/Footer/Footer.args.ts +4 -16
- package/src/components/Footer/Footer.tsx +41 -37
- package/src/components/List/List.props.ts +2 -10
- package/src/components/List/List.tsx +17 -22
- package/src/components/List/ListItem.props.ts +0 -7
- package/src/components/List/ListItem.tsx +6 -11
- package/src/components/Navigation/Navigation.tsx +5 -5
- package/src/components/Pagination/Pagination.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/setup.ts +6 -0
- package/src/stories/Accordion/Accordion.stories.tsx +145 -0
- package/src/stories/Breadcrumb/Breadcrumb.mdx +17 -0
- package/src/stories/Breadcrumb/Breadcrumb.stories.tsx +20 -0
- package/src/stories/Button/Button.mdx +94 -0
- package/src/stories/Button/Button.stories.tsx +68 -0
- package/src/stories/Callout/Callout.mdx +35 -0
- package/src/stories/Callout/Callout.stories.tsx +43 -0
- package/src/stories/Card/DataCard.stories.tsx +45 -0
- package/src/stories/Card/DetailCard.stories.tsx +41 -0
- package/src/stories/Card/FactlistCard.stories.tsx +48 -0
- package/src/stories/Card/FeatureCard.stories.tsx +56 -0
- package/src/stories/Card/MultilinkCard.stories.tsx +48 -0
- package/src/stories/Card/PromoCard.stories.tsx +48 -0
- package/src/stories/Card/StatCard.stories.tsx +45 -0
- package/src/stories/Card/TextCard.stories.tsx +45 -0
- package/src/stories/CardGroup/CardGroup.mdx +17 -0
- package/src/stories/CardGroup/CardGroup.stories.tsx +50 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +118 -0
- package/src/stories/ContextMenu/ContextMenu.stories.tsx +83 -0
- package/src/stories/DatePicker/DatePicker.stories.tsx +110 -0
- package/src/stories/Dropdown/Dropdown.stories.tsx +145 -0
- package/src/stories/Empty/Empty.stories.tsx +53 -0
- package/src/stories/Fieldset/Fieldset.stories.tsx +167 -0
- package/src/stories/FileUpload/FileUpload.stories.tsx +103 -0
- package/src/stories/Footer/Footer.mdx +17 -0
- package/src/stories/Footer/Footer.stories.tsx +15 -0
- package/src/stories/Form/Form.mdx +58 -0
- package/src/stories/Form/Form.stories.tsx +162 -0
- package/src/stories/GetStarted.mdx +57 -0
- package/src/stories/Heading/Heading.stories.tsx +193 -0
- package/src/stories/Hero/Hero.stories.tsx +68 -0
- package/src/stories/Image/Image.stories.tsx +50 -0
- package/src/stories/Link/Link.stories.tsx +81 -0
- package/src/stories/LinkList/LinkList.args.ts +190 -0
- package/src/stories/LinkList/LinkList.stories.tsx +60 -0
- package/src/stories/List/List.stories.tsx +167 -0
- package/src/stories/Loading/Loading.stories.tsx +97 -0
- package/src/stories/LocalNav/LocalNav.mdx +17 -0
- package/src/stories/LocalNav/LocalNav.stories.tsx +15 -0
- package/src/stories/Logo/Logo.stories.tsx +172 -0
- package/src/stories/LogoGrid/LogoGrid.stories.tsx +59 -0
- package/src/stories/Navigation/Navigation.mdx +17 -0
- package/src/stories/Navigation/Navigation.stories.tsx +15 -0
- package/src/stories/Notification/Notification.stories.tsx +187 -0
- package/src/stories/NumberPicker/NumberPicker.stories.tsx +69 -0
- package/src/stories/Pagination/Pagination.stories.tsx +86 -0
- package/src/stories/Profile/Profile.stories.tsx +64 -0
- package/src/stories/Radio/Radio.stories.tsx +232 -0
- package/src/stories/ReadMore/ReadMore.stories.tsx +59 -0
- package/src/stories/RichText/RichText.stories.tsx +63 -0
- package/src/stories/SearchField/SearchField.stories.tsx +91 -0
- package/src/stories/SocialMedia/SocialMedia.stories.tsx +60 -0
- package/src/stories/TableOfContents/TableOfContents.stories.tsx +55 -0
- package/src/stories/Tabs/Tabs.mdx +17 -0
- package/src/stories/Tabs/Tabs.stories.tsx +25 -0
- package/src/stories/Tag/Tag.stories.tsx +130 -0
- package/src/stories/TextInput/TextInput.stories.tsx +100 -0
- package/src/stories/Textarea/Textarea.stories.tsx +147 -0
- package/src/stories/Toggle/Toggle.stories.tsx +99 -0
- package/src/stories/Tooltip/Tooltip.stories.tsx +82 -0
- package/src/stories/Video/Video.stories.tsx +71 -0
- package/src/stories/Welcome.stories.mdx +37 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/welcome.scss +133 -0
- package/src/types/index.ts +6 -2
- package/lib/cjs/ListCtx-14aa546f.js +0 -9
- package/lib/cjs/components/Cards/Card.js +0 -40
- package/lib/cjs/components/Cards/CardGroup.js +0 -33
- package/lib/cjs/components/Cards/index.js +0 -37
- package/lib/esm/ListCtx-da435fdf.js +0 -6
- package/lib/esm/components/Cards/Card.js +0 -38
- package/lib/esm/components/Cards/CardGroup.js +0 -31
- package/lib/esm/components/Cards/index.js +0 -22
- package/lib/types/react/src/components/Cards/Card.d.ts +0 -4
- package/lib/types/react/src/components/Cards/Card.props.d.ts +0 -307
- package/lib/types/react/src/components/Cards/CardGroup.props.d.ts +0 -16
- package/lib/types/react/src/components/Cards/index.d.ts +0 -11
- package/lib/types/react/src/components/List/ListCtx.d.ts +0 -4
- package/src/components/Cards/Card.args.ts +0 -220
- package/src/components/Cards/Card.props.ts +0 -382
- package/src/components/Cards/Card.tsx +0 -36
- package/src/components/Cards/CardGroup.props.ts +0 -19
- package/src/components/Cards/CardGroup.tsx +0 -54
- package/src/components/Cards/index.ts +0 -22
- package/src/components/List/ListCtx.ts +0 -7
- /package/lib/types/react/src/components/Cards/{CardGroup.d.ts → CardGroup/CardGroup.d.ts} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { Pagination } from "../components/Pagination";
|
|
3
|
+
import paginationArgs from "../components/Pagination/Pagination.args";
|
|
4
|
+
|
|
5
|
+
describe("<Pagination>", () => {
|
|
6
|
+
it("Pagination link should render with a disable class", () => {
|
|
7
|
+
const { container } = render(
|
|
8
|
+
<Pagination {...paginationArgs.firstDisabled} />
|
|
9
|
+
);
|
|
10
|
+
expect(container.children[0]).not.toBeNull();
|
|
11
|
+
const previousPagination = document.querySelector('a[class*="--disable"]');
|
|
12
|
+
expect(previousPagination).not.toBeNull();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("First link should match the args", () => {
|
|
16
|
+
render(<Pagination {...paginationArgs.firstDisabled} />);
|
|
17
|
+
const pagination = document.querySelector('a[class*="--first-page"]');
|
|
18
|
+
expect(pagination).not.toBeNull();
|
|
19
|
+
expect(pagination?.getAttribute("href")).toEqual(
|
|
20
|
+
expect.stringContaining(
|
|
21
|
+
paginationArgs.firstDisabled.firstPageUrl as string
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("Previous link should match the args", () => {
|
|
27
|
+
render(<Pagination {...paginationArgs.firstDisabled} />);
|
|
28
|
+
const pagination = document.querySelector('a[class*="--prev-page"]');
|
|
29
|
+
expect(pagination).not.toBeNull();
|
|
30
|
+
expect(pagination?.getAttribute("href")).toEqual(
|
|
31
|
+
expect.stringContaining(
|
|
32
|
+
paginationArgs.firstDisabled.prevPageUrl as string
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("Next link should match the args", () => {
|
|
38
|
+
render(<Pagination {...paginationArgs.firstDisabled} />);
|
|
39
|
+
const pagination = document.querySelector('a[class*="--next-page"]');
|
|
40
|
+
expect(pagination).not.toBeNull();
|
|
41
|
+
expect(pagination?.getAttribute("href")).toEqual(
|
|
42
|
+
expect.stringContaining(
|
|
43
|
+
paginationArgs.firstDisabled.nextPageUrl as string
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("Last link should match the args", () => {
|
|
49
|
+
render(<Pagination {...paginationArgs.firstDisabled} />);
|
|
50
|
+
const pagination = document.querySelector('a[class*="--last-page"]');
|
|
51
|
+
expect(pagination).not.toBeNull();
|
|
52
|
+
expect(pagination?.getAttribute("href")).toEqual(
|
|
53
|
+
expect.stringContaining(
|
|
54
|
+
paginationArgs.firstDisabled.lastPageUrl as string
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { Profile } from "../components/Profile";
|
|
3
|
+
import profileArgs from "../components/Profile/Profile.args";
|
|
4
|
+
|
|
5
|
+
describe("<Profile>", () => {
|
|
6
|
+
it("Should render Profile with content from name prop.", () => {
|
|
7
|
+
const { container } = render(<Profile {...profileArgs.basic} />);
|
|
8
|
+
expect(container.children[0]).not.toBeNull();
|
|
9
|
+
const nameElement = document.querySelector('[class*="--name"]');
|
|
10
|
+
expect(nameElement?.textContent).toEqual(profileArgs?.basic?.name);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("Should render Profile with content from avatar prop.", () => {
|
|
14
|
+
const { container } = render(<Profile {...profileArgs.basic} />);
|
|
15
|
+
expect(container.children[0]).not.toBeNull();
|
|
16
|
+
const imgElement = document.querySelector('[class*="--avatar"]');
|
|
17
|
+
expect(imgElement).toHaveAttribute("src", profileArgs?.basic?.avatar);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("Should render Profile with content from role prop.", () => {
|
|
21
|
+
const { container } = render(<Profile {...profileArgs.hasrole} />);
|
|
22
|
+
expect(container.children[0]).not.toBeNull();
|
|
23
|
+
const roleElement = document.querySelector('[class*="--role"]');
|
|
24
|
+
expect(roleElement?.textContent).toEqual(profileArgs?.hasrole?.role);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("Should render Profile with content from description prop.", () => {
|
|
28
|
+
const { container } = render(<Profile {...profileArgs.hasdescription} />);
|
|
29
|
+
expect(container.children[0]).not.toBeNull();
|
|
30
|
+
const descriptionElement = document.querySelector(
|
|
31
|
+
'[class*="--description"]'
|
|
32
|
+
);
|
|
33
|
+
expect(descriptionElement?.textContent).toEqual(
|
|
34
|
+
profileArgs?.hasdescription?.description
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("Should render Profile with content from link prop.", () => {
|
|
39
|
+
const { container } = render(<Profile {...profileArgs.haslink} />);
|
|
40
|
+
expect(container.children[0]).not.toBeNull();
|
|
41
|
+
const linkElement = document.querySelector('[class*="--link"] a');
|
|
42
|
+
expect(linkElement?.textContent).toEqual(profileArgs?.haslink?.link?.label);
|
|
43
|
+
expect(linkElement).toHaveAttribute(
|
|
44
|
+
"href",
|
|
45
|
+
profileArgs?.haslink?.link?.url
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { ReadMore } from "../components/ReadMore";
|
|
4
|
+
import readMoreArgs from "../components/ReadMore/ReadMore.args";
|
|
5
|
+
|
|
6
|
+
describe("<ReadMore>", () => {
|
|
7
|
+
it("Should render RichText `div` with content.", () => {
|
|
8
|
+
const { container } = render(<ReadMore {...readMoreArgs.base} />);
|
|
9
|
+
expect(container.children[0]).not.toBeNull();
|
|
10
|
+
const richTextElement = document.querySelector('div[class*="--richtext"]');
|
|
11
|
+
const excerpt = new DOMParser().parseFromString(
|
|
12
|
+
readMoreArgs.base.excerpt,
|
|
13
|
+
"text/html"
|
|
14
|
+
).documentElement.textContent;
|
|
15
|
+
expect(richTextElement?.textContent).toEqual(excerpt);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("Should render `button` with correct label from prop buttonlabel", () => {
|
|
19
|
+
render(<ReadMore {...readMoreArgs.base} />);
|
|
20
|
+
const buttonElement = screen.getAllByRole("button");
|
|
21
|
+
expect(buttonElement).not.toBeNull();
|
|
22
|
+
expect(buttonElement[0].textContent).toEqual(
|
|
23
|
+
readMoreArgs?.base?.buttonlabel?.closed
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("Should change contents of RichText `div` with new content.", () => {
|
|
28
|
+
render(<ReadMore {...readMoreArgs.base} />);
|
|
29
|
+
const richTextElement = document.querySelector(
|
|
30
|
+
'div[class*="--richtext"]'
|
|
31
|
+
) as Element;
|
|
32
|
+
const fulltext = new DOMParser().parseFromString(
|
|
33
|
+
readMoreArgs.open.fulltext,
|
|
34
|
+
"text/html"
|
|
35
|
+
).documentElement.textContent;
|
|
36
|
+
userEvent.click(
|
|
37
|
+
screen.getByText(readMoreArgs?.base?.buttonlabel?.closed as string, {
|
|
38
|
+
selector: "button",
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
expect(richTextElement.textContent).toEqual(fulltext);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { RichText } from "../components/RichText";
|
|
3
|
+
import richTextArgs from "../components/RichText/richText.args";
|
|
4
|
+
|
|
5
|
+
describe("<RichText>", () => {
|
|
6
|
+
it("Should render `div` with content.", () => {
|
|
7
|
+
const { container } = render(<RichText {...richTextArgs.richtext} />);
|
|
8
|
+
// Parse the content as a domstring and get the text content
|
|
9
|
+
const textContent = new DOMParser().parseFromString(
|
|
10
|
+
richTextArgs.richtext.content,
|
|
11
|
+
"text/html"
|
|
12
|
+
).documentElement.textContent;
|
|
13
|
+
expect(container.children[0]).not.toBeNull();
|
|
14
|
+
expect(container.children[0].textContent).toEqual(textContent);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { SearchField } from "../components/SearchField";
|
|
3
|
+
import searchFieldArgs from "../components/SearchField/SearchField.args";
|
|
4
|
+
|
|
5
|
+
describe("<SearchField>", () => {
|
|
6
|
+
it("Should render `search field` with correct label from prop input.placeholder", () => {
|
|
7
|
+
const { container } = render(
|
|
8
|
+
<SearchField {...searchFieldArgs.searchfield} />
|
|
9
|
+
);
|
|
10
|
+
expect(container.children[0]).not.toBeNull();
|
|
11
|
+
const inputElement = screen.getByPlaceholderText(
|
|
12
|
+
searchFieldArgs.searchfield.input?.placeholder as string
|
|
13
|
+
);
|
|
14
|
+
expect(inputElement).not.toBeNull();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("Should render `search field input` with disabled attribute", () => {
|
|
18
|
+
const { container } = render(
|
|
19
|
+
<SearchField {...searchFieldArgs.searchfielddisabled} />
|
|
20
|
+
);
|
|
21
|
+
expect(container.children[0]).not.toBeNull();
|
|
22
|
+
const inputElement = screen.getByPlaceholderText(
|
|
23
|
+
searchFieldArgs.searchfielddisabled.input?.placeholder as string
|
|
24
|
+
);
|
|
25
|
+
expect(inputElement).toHaveAttribute("disabled", "");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('calls "callback" prop on button click', () => {
|
|
29
|
+
const onClick = jest.fn();
|
|
30
|
+
render(<SearchField {...searchFieldArgs.searchfield} callback={onClick} />);
|
|
31
|
+
const buttonElement = screen.getAllByRole("button");
|
|
32
|
+
fireEvent.click(buttonElement[0]);
|
|
33
|
+
expect(onClick).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { TableOfContents } from "../components/TableOfContents";
|
|
3
|
+
import tableOfContentsArgs from "../components/TableOfContents/TableOfContents.args";
|
|
4
|
+
|
|
5
|
+
describe("<TableOfContents>", () => {
|
|
6
|
+
it("Should render `ul` with some items.", () => {
|
|
7
|
+
const { container } = render(
|
|
8
|
+
<TableOfContents {...tableOfContentsArgs.toc} />
|
|
9
|
+
);
|
|
10
|
+
expect(container).not.toBeNull();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { TagSet } from "../components/Tag";
|
|
3
|
+
import tagSetArgs from "../components/Tag/TagSet.args";
|
|
4
|
+
|
|
5
|
+
describe("<TagSet>", () => {
|
|
6
|
+
it("Should render `button` with correct class name from type prop", () => {
|
|
7
|
+
const { container } = render(<TagSet {...tagSetArgs.tag} />);
|
|
8
|
+
expect(container).not.toBeNull();
|
|
9
|
+
});
|
|
10
|
+
});
|