@madie/madie-design-system 1.2.62 → 2.0.1
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/.babelrc +14 -2
- package/.eslintrc.js +1 -1
- package/.storybook/.babelrc +2 -1
- package/.storybook/main.js +3 -11
- package/.storybook/preview.js +1 -1
- package/components/Accordion/index.jsx +32 -36
- package/components/AutoComplete/AutoComplete.jsx +2 -17
- package/components/Button/Button.stories.js +0 -7
- package/components/Button/index.js +34 -44
- package/components/DateField/DateField.jsx +2 -15
- package/components/DateField/DateField.stories.jsx +23 -10
- package/components/DateTimeField/DateTimeField.jsx +7 -11
- package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
- package/components/InputLabel/index.jsx +1 -6
- package/components/Instant/Instant.stories.js +14 -6
- package/components/Instant/index.jsx +0 -16
- package/components/Link/index.js +14 -33
- package/components/MadieAlert/MadieAlert.stories.js +35 -29
- package/components/MadieAlert/index.jsx +5 -44
- package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -32
- package/components/MadieConfirmDialog/index.jsx +0 -8
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -24
- package/components/MadieDeleteDialog/index.jsx +0 -7
- package/components/MadieDialog/MadieDialog.stories.js +45 -121
- package/components/MadieDialog/index.jsx +4 -23
- package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -12
- package/components/MadieDiscardDialog/index.jsx +0 -7
- package/components/MadieSpinner/MadieSpinner.stories.js +1 -9
- package/components/MadieSpinner/index.jsx +0 -5
- package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
- package/components/MadieTooltip/index.jsx +0 -6
- package/components/MadieTooltipIcon/index.jsx +0 -5
- package/components/Modal/Modal.jsx +31 -43
- package/components/Modal/Modal.stories.js +18 -89
- package/components/Modal/index.jsx +6 -8
- package/components/NumberInput/NumberInput.stories.js +50 -67
- package/components/NumberInput/index.jsx +0 -13
- package/components/Pagination/index.jsx +0 -17
- package/components/Popover/Popover.stories.js +6 -14
- package/components/Popover/index.js +0 -23
- package/components/RadioButton/RadioButton.jsx +5 -15
- package/components/RadioButton/RadioButton.stories.jsx +6 -2
- package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +3 -8
- package/components/ReadOnlyTextField/index.jsx +1 -9
- package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
- package/components/RichTextEditor/index.jsx +14 -30
- package/components/SanitizedContent/index.jsx +0 -8
- package/components/Search/Search.stories.js +2 -4
- package/components/Search/index.js +26 -40
- package/components/Select/Select.stories.js +59 -164
- package/components/Select/index.jsx +2 -17
- package/components/Tabs/Tab.js +29 -25
- package/components/Tabs/TabPanel.js +15 -19
- package/components/Tabs/Tabs.stories.js +43 -211
- package/components/Tabs/index.js +10 -28
- package/components/TextArea/TextArea.stories.js +87 -113
- package/components/TextArea/index.jsx +2 -14
- package/components/TextField/TextField.stories.js +100 -129
- package/components/TextField/index.jsx +2 -17
- package/components/TimeField/TimeField.jsx +0 -10
- package/components/TimeField/TimeField.stories.js +18 -8
- package/components/Toast/Toast.stories.js +42 -102
- package/components/Toast/index.jsx +0 -14
- package/components/TruncateText/TruncateText.stories.js +22 -17
- package/components/TruncateText/index.js +0 -8
- package/components/hooks/useGetConfig.js +2 -2
- package/components/{index.js → index.mjs} +37 -57
- package/dist/index.js +3 -1
- package/dist/index.js.LICENSE.txt +16 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.html +1 -1
- package/dist/react/index.mjs +103 -0
- package/dist/react/{index.js.LICENSE.txt → index.mjs.LICENSE.txt} +3 -52
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/package.json +1 -0
- package/eslint.config.cjs +59 -0
- package/index.js +7 -9
- package/jest.config.mjs +10 -0
- package/lib/Chevron.jsx +2 -10
- package/package.json +57 -82
- package/styles/_main.scss +4 -3
- package/test/components/Accordion.test.js +1 -1
- package/test/components/AutoComplete.test.js +11 -6
- package/test/components/Button.test.js +13 -19
- package/test/components/DateField.test.js +25 -29
- package/test/components/DateTimeField.test.js +21 -25
- package/test/components/Instant.test.js +1 -1
- package/test/components/MadieAlert.test.js +22 -22
- package/test/components/MadieConfirmDialog.test.js +42 -64
- package/test/components/MadieDeleteDialog.test.js +51 -69
- package/test/components/MadieDialog.test.js +13 -13
- package/test/components/MadieDiscardDialog.test.js +28 -45
- package/test/components/MadieSpinner.test.js +12 -17
- package/test/components/Modal.test.js +115 -0
- package/test/components/Pagination.test.js +2 -2
- package/test/components/RadioButton.test.js +7 -7
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +90 -6
- package/test/components/Search.test.js +75 -0
- package/test/components/Select.test.js +97 -107
- package/test/components/Tabs.test.js +22 -24
- package/test/components/TextArea.test.js +78 -92
- package/test/components/TextField.test.js +128 -147
- package/test/components/Toast.test.js +67 -78
- package/test/components/TruncateText.test.js +75 -0
- package/test/components/index.test.js +23 -0
- package/webpack.config.mjs +79 -0
- package/webpack.config.react.mjs +72 -0
- package/.eslintignore +0 -5
- package/components/Alert/Alert.stories.js +0 -70
- package/components/Alert/index.js +0 -55
- package/components/Breadcrumb/Breadcrumb.md +0 -28
- package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
- package/components/Breadcrumb/index.js +0 -92
- package/components/CalloutBox/CalloutBox.stories.js +0 -94
- package/components/CalloutBox/index.js +0 -109
- package/components/Card/Card.stories.js +0 -163
- package/components/Card/index.js +0 -144
- package/components/Dropdown/Dropdown.stories.js +0 -94
- package/components/Dropdown/index.js +0 -85
- package/components/Error/Collapsible.jsx +0 -93
- package/components/Error/ErrorUI.jsx +0 -31
- package/components/Error/error.js +0 -26
- package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
- package/components/FlashNotification/index.js +0 -30
- package/components/Footer/Footer.stories.js +0 -20
- package/components/Footer/FooterUI.jsx +0 -137
- package/components/Footer/LegacyFooterUI.jsx +0 -204
- package/components/Footer/SocialLinks.jsx +0 -63
- package/components/Footer/Subscribe.jsx +0 -34
- package/components/Footer/footer.js +0 -30
- package/components/Infotip/Infotip.jsx +0 -75
- package/components/Infotip/Infotip.stories.js +0 -52
- package/components/Infotip/InfotipIcon.jsx +0 -41
- package/components/Infotip/index.js +0 -3
- package/components/Link/Link.stories.js +0 -82
- package/components/NotificationBanner/NotificationBanner.stories.js +0 -23
- package/components/NotificationBanner/index.js +0 -279
- package/components/Spinner/index.js +0 -9
- package/components/TextInput/TextInput.stories.js +0 -118
- package/components/TextInput/index.js +0 -137
- package/components/Tooltip/Tooltip.jsx +0 -88
- package/components/Tooltip/Tooltip.stories.js +0 -80
- package/components/Tooltip/index.js +0 -3
- package/components/Tooltip/position.js +0 -76
- package/components/UnwrappedSpinner/index.js +0 -8
- package/dist/browser.js +0 -1
- package/dist/react/index.js +0 -185
- package/dist/react/index.js.map +0 -1
- package/jest.config.js +0 -17
- package/test/components/ErrorUI.test.js +0 -32
- package/test/components/FooterUI.test.js +0 -122
- package/test/components/Infotip.test.js +0 -76
- package/test/components/Tooltip.test.js +0 -147
- package/webpack.config.js +0 -124
- package/webpack.config.react.js +0 -104
|
@@ -2,113 +2,105 @@ import * as React from "react";
|
|
|
2
2
|
import "@testing-library/jest-dom";
|
|
3
3
|
import { describe, expect, test } from "@jest/globals";
|
|
4
4
|
import Select from "../../components/Select/index";
|
|
5
|
-
import { act, Simulate } from "react-dom/test-utils";
|
|
6
5
|
|
|
7
6
|
import { render, fireEvent, screen } from "@testing-library/react";
|
|
8
7
|
|
|
9
8
|
import { MenuItem } from "@mui/material";
|
|
10
9
|
|
|
11
10
|
describe("Select", () => {
|
|
11
|
+
const { getByTestId, findByText, getByRole } = screen;
|
|
12
12
|
const options = [
|
|
13
13
|
{ key: "key1", value: "value1", testId: "testid1", name: "name1" },
|
|
14
14
|
{ key: "key2", value: "value2", testId: "testid2", name: "name2" },
|
|
15
15
|
{ key: "key3", value: "value2", testId: "testid3", name: "name3" },
|
|
16
16
|
];
|
|
17
17
|
test("Select exists, and simulates input correctly", async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
expect(inputNode.value).toBe("value1");
|
|
47
|
-
});
|
|
18
|
+
render(
|
|
19
|
+
<Select
|
|
20
|
+
placeHolder={{ name: "placeholder", value: "" }}
|
|
21
|
+
required
|
|
22
|
+
label="Test"
|
|
23
|
+
id="test-select"
|
|
24
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
25
|
+
data-testid="test-select"
|
|
26
|
+
size="small"
|
|
27
|
+
options={options.map(({ key, value, testId, name }) => {
|
|
28
|
+
return (
|
|
29
|
+
<MenuItem
|
|
30
|
+
key={key}
|
|
31
|
+
value={value}
|
|
32
|
+
data-testid={`option-${testId}`}
|
|
33
|
+
>
|
|
34
|
+
{name}
|
|
35
|
+
</MenuItem>
|
|
36
|
+
);
|
|
37
|
+
})}
|
|
38
|
+
/>,
|
|
39
|
+
);
|
|
40
|
+
const selectNode = await getByTestId("test-select");
|
|
41
|
+
fireEvent.click(selectNode);
|
|
42
|
+
const inputNode = await getByTestId("test-input");
|
|
43
|
+
fireEvent.select(inputNode, { target: { value: "value1" } });
|
|
44
|
+
fireEvent.change(inputNode);
|
|
45
|
+
expect(inputNode.value).toBe("value1");
|
|
48
46
|
});
|
|
49
47
|
test("Placeholder value renders", async () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
expect(inputNode.value).toBe("");
|
|
76
|
-
});
|
|
48
|
+
render(
|
|
49
|
+
<Select
|
|
50
|
+
placeHolder={{ name: "placeholder", value: "" }}
|
|
51
|
+
required
|
|
52
|
+
label="Test"
|
|
53
|
+
id="test-select"
|
|
54
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
55
|
+
data-testid="test-select"
|
|
56
|
+
size="small"
|
|
57
|
+
value=""
|
|
58
|
+
options={options.map(({ key, value, testId, name }) => {
|
|
59
|
+
return (
|
|
60
|
+
<MenuItem
|
|
61
|
+
key={key}
|
|
62
|
+
value={value}
|
|
63
|
+
data-testid={`option-${testId}`}
|
|
64
|
+
>
|
|
65
|
+
{name}
|
|
66
|
+
</MenuItem>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
/>,
|
|
70
|
+
);
|
|
71
|
+
const inputNode = await getByTestId("test-input");
|
|
72
|
+
expect(inputNode.value).toBe("");
|
|
77
73
|
});
|
|
78
74
|
test("Select exists, and simulates input correctly", async () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
expect(inputNode.value).toBe("");
|
|
94
|
-
});
|
|
75
|
+
render(
|
|
76
|
+
<Select
|
|
77
|
+
label="Test"
|
|
78
|
+
value=""
|
|
79
|
+
id="test-select"
|
|
80
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
81
|
+
data-testid="test-select"
|
|
82
|
+
size="small"
|
|
83
|
+
/>,
|
|
84
|
+
);
|
|
85
|
+
const selectNode = await getByTestId("test-select");
|
|
86
|
+
fireEvent.click(selectNode);
|
|
87
|
+
const inputNode = await getByTestId("test-input");
|
|
88
|
+
expect(inputNode.value).toBe("");
|
|
95
89
|
});
|
|
96
90
|
test("Helper text exists", async () => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(helperText).toBeInTheDocument();
|
|
111
|
-
});
|
|
91
|
+
render(
|
|
92
|
+
<Select
|
|
93
|
+
helperText="helper text"
|
|
94
|
+
label="Test"
|
|
95
|
+
value=""
|
|
96
|
+
id="test-select"
|
|
97
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
98
|
+
data-testid="test-select"
|
|
99
|
+
size="small"
|
|
100
|
+
/>,
|
|
101
|
+
);
|
|
102
|
+
const helperText = await findByText("helper text");
|
|
103
|
+
expect(helperText).toBeInTheDocument();
|
|
112
104
|
});
|
|
113
105
|
|
|
114
106
|
test("Select renders disabled", () => {
|
|
@@ -122,28 +114,26 @@ describe("Select", () => {
|
|
|
122
114
|
inputProps={{ "data-testid": "test-input" }}
|
|
123
115
|
data-testid="test-select"
|
|
124
116
|
size="small"
|
|
125
|
-
|
|
117
|
+
/>,
|
|
126
118
|
);
|
|
127
|
-
const value =
|
|
119
|
+
const value = getByRole("textbox");
|
|
128
120
|
expect(value).toHaveTextContent("-");
|
|
129
121
|
expect(value).toHaveAttribute("readOnly");
|
|
130
122
|
});
|
|
131
123
|
test("Select renders error", async () => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
expect(helperText).toBeInTheDocument();
|
|
147
|
-
});
|
|
124
|
+
render(
|
|
125
|
+
<Select
|
|
126
|
+
error
|
|
127
|
+
helperText="helper text"
|
|
128
|
+
label="Test"
|
|
129
|
+
value=""
|
|
130
|
+
id="test-select"
|
|
131
|
+
inputProps={{ "data-testid": "test-input" }}
|
|
132
|
+
data-testid="test-select"
|
|
133
|
+
size="small"
|
|
134
|
+
/>,
|
|
135
|
+
);
|
|
136
|
+
const helperText = await findByText("helper text");
|
|
137
|
+
expect(helperText).toBeInTheDocument();
|
|
148
138
|
});
|
|
149
139
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
2
|
import { describe, expect, test } from "@jest/globals";
|
|
3
|
-
import {
|
|
4
|
-
import { render, waitFor } from "@testing-library/react";
|
|
3
|
+
import { render, waitFor, screen } from "@testing-library/react";
|
|
5
4
|
import Tab from "../../components/Tabs/Tab";
|
|
6
5
|
import Tabs from "../../components/Tabs/index";
|
|
7
6
|
import React from "react";
|
|
8
7
|
|
|
9
8
|
describe("Tabs", () => {
|
|
9
|
+
const { findByTestId } = screen;
|
|
10
10
|
const Navigations = () => {
|
|
11
11
|
return (
|
|
12
12
|
<div>
|
|
@@ -265,29 +265,27 @@ describe("Tabs", () => {
|
|
|
265
265
|
};
|
|
266
266
|
|
|
267
267
|
test("All Tab components render. ", async () => {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const largeD = await findByTestId("large-d");
|
|
268
|
+
render(<Navigations />);
|
|
269
|
+
const standardA = await findByTestId("standard-a");
|
|
270
|
+
const standardB = await findByTestId("standard-b");
|
|
271
|
+
const standardC = await findByTestId("standard-c");
|
|
272
|
+
const verticalC = await findByTestId("v-c");
|
|
273
|
+
const standardD = await findByTestId("standard-d");
|
|
274
|
+
const largeA = await findByTestId("large-a");
|
|
275
|
+
const largeB = await findByTestId("large-b");
|
|
276
|
+
const largeC = await findByTestId("large-c");
|
|
277
|
+
const largeD = await findByTestId("large-d");
|
|
279
278
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
});
|
|
279
|
+
await waitFor(() => {
|
|
280
|
+
expect(standardA).toBeInTheDocument();
|
|
281
|
+
expect(standardB).toBeInTheDocument();
|
|
282
|
+
expect(standardC).toBeInTheDocument();
|
|
283
|
+
expect(verticalC).toBeInTheDocument();
|
|
284
|
+
expect(standardD).toBeInTheDocument();
|
|
285
|
+
expect(largeA).toBeInTheDocument();
|
|
286
|
+
expect(largeB).toBeInTheDocument();
|
|
287
|
+
expect(largeC).toBeInTheDocument();
|
|
288
|
+
expect(largeD).toBeInTheDocument();
|
|
291
289
|
});
|
|
292
290
|
});
|
|
293
291
|
});
|
|
@@ -1,51 +1,45 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import "@testing-library/jest-dom";
|
|
3
3
|
import { describe, expect, test } from "@jest/globals";
|
|
4
4
|
import TextArea from "../../components/TextArea/index";
|
|
5
|
-
import {
|
|
6
|
-
import { render, screen } from "@testing-library/react";
|
|
5
|
+
import { render, screen, waitFor, fireEvent } from "@testing-library/react";
|
|
7
6
|
import userEvent from "@testing-library/user-event";
|
|
8
7
|
|
|
9
|
-
|
|
10
8
|
describe("TextArea", () => {
|
|
11
9
|
test("TextArea exists, and simulates input correctly", async () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
userEvent.type(textNode, "newVal");
|
|
29
|
-
Simulate.change(textNode);
|
|
10
|
+
const { findByTestId, getByTestId } = render(
|
|
11
|
+
<TextArea
|
|
12
|
+
placeholder="test Name"
|
|
13
|
+
required
|
|
14
|
+
label="test Name"
|
|
15
|
+
id="testName"
|
|
16
|
+
data-testid="test-name-text-field"
|
|
17
|
+
disabled={false}
|
|
18
|
+
/>,
|
|
19
|
+
);
|
|
20
|
+
expect(await findByTestId("test-name-text-field")).toBeInTheDocument();
|
|
21
|
+
const textNode = await getByTestId("test-name-text-field");
|
|
22
|
+
expect(textNode).toBeInTheDocument();
|
|
23
|
+
userEvent.type(textNode, "newVal");
|
|
24
|
+
fireEvent.change(textNode);
|
|
25
|
+
await waitFor(() => {
|
|
30
26
|
expect(textNode.value).toBe("newVal");
|
|
31
27
|
});
|
|
32
28
|
});
|
|
33
29
|
test("TextArea renders with helper text", async () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
expect(helperText).toBeInTheDocument();
|
|
48
|
-
});
|
|
30
|
+
const { findByText } = render(
|
|
31
|
+
<TextArea
|
|
32
|
+
error={false}
|
|
33
|
+
placeholder="test Name"
|
|
34
|
+
helperText="helper text"
|
|
35
|
+
label="test Name"
|
|
36
|
+
id="testName"
|
|
37
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
38
|
+
data-testid="test-name-text-field"
|
|
39
|
+
/>,
|
|
40
|
+
);
|
|
41
|
+
const helperText = await findByText("helper text");
|
|
42
|
+
expect(helperText).toBeInTheDocument();
|
|
49
43
|
});
|
|
50
44
|
test("renders TextArea for disabled mode", async () => {
|
|
51
45
|
render(
|
|
@@ -55,72 +49,64 @@ describe("TextArea", () => {
|
|
|
55
49
|
helperText="helper text"
|
|
56
50
|
label="test Name"
|
|
57
51
|
id="testName"
|
|
58
|
-
inputProps={{"data-testid": "test-name-input"}}
|
|
52
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
59
53
|
data-testid="test-name-text-field"
|
|
60
54
|
value="test value"
|
|
61
|
-
|
|
55
|
+
/>,
|
|
62
56
|
);
|
|
63
57
|
const textArea = await screen.findByRole("textbox");
|
|
64
58
|
expect(textArea).toHaveTextContent("test value");
|
|
65
59
|
expect(textArea).toHaveAttribute("readOnly");
|
|
66
60
|
});
|
|
67
61
|
test("HelperText renders errored", async () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
expect(helperText).toBeInTheDocument();
|
|
82
|
-
});
|
|
62
|
+
const { findByText } = render(
|
|
63
|
+
<TextArea
|
|
64
|
+
error
|
|
65
|
+
placeholder="test Name"
|
|
66
|
+
helperText="helper text"
|
|
67
|
+
label="test Name"
|
|
68
|
+
id="testName"
|
|
69
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
70
|
+
data-testid="test-name-text-field"
|
|
71
|
+
/>,
|
|
72
|
+
);
|
|
73
|
+
const helperText = await findByText("helper text");
|
|
74
|
+
expect(helperText).toBeInTheDocument();
|
|
83
75
|
});
|
|
84
76
|
test("TextArea renders with default propTypes left out", async () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(helperText).toBeInTheDocument();
|
|
100
|
-
});
|
|
77
|
+
const { findByText } = render(
|
|
78
|
+
<TextArea
|
|
79
|
+
// error purposely omitted
|
|
80
|
+
// disabled purposely omitted
|
|
81
|
+
placeholder="test Name"
|
|
82
|
+
helperText="helper text"
|
|
83
|
+
label="test Name"
|
|
84
|
+
id="testName"
|
|
85
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
86
|
+
data-testid="test-name-text-field"
|
|
87
|
+
/>,
|
|
88
|
+
);
|
|
89
|
+
const helperText = await findByText("helper text");
|
|
90
|
+
expect(helperText).toBeInTheDocument();
|
|
101
91
|
});
|
|
102
92
|
test("TextArea shows maxLength", async () => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
Simulate.change(textNode);
|
|
122
|
-
const maxLength = await findByText("/10 Characters");
|
|
123
|
-
expect(maxLength).toBeInTheDocument();
|
|
124
|
-
});
|
|
93
|
+
const { findByTestId, getByTestId, findByText } = render(
|
|
94
|
+
<TextArea
|
|
95
|
+
placeholder="test Name"
|
|
96
|
+
required
|
|
97
|
+
label="test Name"
|
|
98
|
+
id="testName"
|
|
99
|
+
data-testid="test-name-text-field"
|
|
100
|
+
disabled={false}
|
|
101
|
+
maxLength={10}
|
|
102
|
+
/>,
|
|
103
|
+
);
|
|
104
|
+
expect(await findByTestId("test-name-text-field")).toBeInTheDocument();
|
|
105
|
+
const textNode = await getByTestId("test-name-text-field");
|
|
106
|
+
expect(textNode).toBeInTheDocument();
|
|
107
|
+
userEvent.type(textNode, "newVal");
|
|
108
|
+
fireEvent.change(textNode);
|
|
109
|
+
const maxLength = await findByText("/10 Characters");
|
|
110
|
+
expect(maxLength).toBeInTheDocument();
|
|
125
111
|
});
|
|
126
112
|
});
|