@dxc-technology/halstack-react 0.0.0-eb2a4cc → 0.0.0-ebb089f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/babel.config.js +5 -2
- package/dist/BackgroundColorContext.js +46 -0
- package/dist/ThemeContext.js +237 -2
- package/dist/V3Select/V3Select.js +549 -0
- package/dist/V3Select/index.d.ts +27 -0
- package/dist/V3Textarea/V3Textarea.js +264 -0
- package/dist/V3Textarea/index.d.ts +27 -0
- package/dist/accordion/Accordion.js +170 -81
- package/dist/accordion/index.d.ts +28 -0
- package/dist/accordion-group/AccordionGroup.js +186 -0
- package/dist/accordion-group/index.d.ts +16 -0
- package/dist/alert/Alert.js +184 -83
- package/dist/alert/index.d.ts +51 -0
- package/dist/badge/Badge.js +63 -0
- package/dist/box/Box.js +31 -23
- package/dist/box/index.d.ts +25 -0
- package/dist/button/Button.js +84 -29
- package/dist/button/Button.stories.js +14 -211
- package/dist/button/index.d.ts +24 -0
- package/dist/card/Card.js +72 -35
- package/dist/card/index.d.ts +22 -0
- package/dist/checkbox/Checkbox.js +107 -32
- package/dist/checkbox/index.d.ts +24 -0
- package/dist/chip/Chip.js +135 -40
- package/dist/chip/index.d.ts +22 -0
- package/dist/common/RequiredComponent.js +2 -8
- package/dist/common/utils.js +2 -22
- package/dist/common/variables.js +1472 -159
- package/dist/date/Date.js +81 -59
- package/dist/date/index.d.ts +27 -0
- package/dist/date-input/DateInput.js +400 -0
- package/dist/date-input/index.d.ts +95 -0
- package/dist/dialog/Dialog.js +61 -36
- package/dist/dialog/index.d.ts +18 -0
- package/dist/dropdown/Dropdown.js +226 -94
- package/dist/dropdown/index.d.ts +26 -0
- package/dist/file-input/FileInput.js +644 -0
- package/dist/file-input/FileItem.js +287 -0
- package/dist/file-input/index.d.ts +81 -0
- package/dist/footer/Footer.js +122 -47
- package/dist/footer/Icons.js +77 -0
- package/dist/footer/index.d.ts +25 -0
- package/dist/header/Header.js +211 -91
- package/dist/header/Icons.js +59 -0
- package/dist/header/index.d.ts +25 -0
- package/dist/heading/Heading.js +93 -22
- package/dist/heading/index.d.ts +17 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +290 -104
- package/dist/input-text/index.d.ts +36 -0
- package/dist/layout/ApplicationLayout.js +327 -0
- package/dist/layout/Icons.js +55 -0
- package/dist/link/Link.js +136 -35
- package/dist/link/index.d.ts +23 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +112 -16
- package/dist/number-input/NumberInput.js +136 -0
- package/dist/number-input/NumberInputContext.js +16 -0
- package/dist/number-input/index.d.ts +113 -0
- package/dist/paginator/Icons.js +66 -0
- package/dist/paginator/Paginator.js +184 -57
- package/dist/paginator/index.d.ts +20 -0
- package/dist/password-input/PasswordInput.js +203 -0
- package/dist/password-input/index.d.ts +94 -0
- package/dist/progress-bar/ProgressBar.js +97 -44
- package/dist/progress-bar/index.d.ts +18 -0
- package/dist/radio/Radio.js +39 -21
- package/dist/radio/index.d.ts +23 -0
- package/dist/resultsetTable/ResultsetTable.js +93 -69
- package/dist/resultsetTable/index.d.ts +19 -0
- package/dist/select/Select.js +957 -262
- package/dist/select/index.d.ts +131 -0
- package/dist/sidenav/Sidenav.js +87 -125
- package/dist/sidenav/index.d.ts +13 -0
- package/dist/slider/Slider.js +219 -73
- package/dist/slider/index.d.ts +29 -0
- package/dist/spinner/Spinner.js +249 -64
- package/dist/spinner/index.d.ts +17 -0
- package/dist/switch/Switch.js +51 -26
- package/dist/switch/index.d.ts +24 -0
- package/dist/table/Table.js +63 -15
- package/dist/table/index.d.ts +13 -0
- package/dist/tabs/Tabs.js +208 -35
- package/dist/tabs/index.d.ts +19 -0
- package/dist/tag/Tag.js +100 -35
- package/dist/tag/index.d.ts +24 -0
- package/dist/text-input/TextInput.js +974 -0
- package/dist/text-input/index.d.ts +135 -0
- package/dist/textarea/Textarea.js +250 -107
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle/Toggle.js +16 -19
- package/dist/toggle/index.d.ts +21 -0
- package/dist/toggle-group/ToggleGroup.js +327 -0
- package/dist/toggle-group/index.d.ts +21 -0
- package/dist/upload/Upload.js +13 -8
- package/dist/upload/buttons-upload/ButtonsUpload.js +35 -25
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +84 -37
- package/dist/upload/dragAndDropArea/Icons.js +39 -0
- package/dist/upload/file-upload/FileToUpload.js +64 -33
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/files-upload/FilesToUpload.js +16 -16
- package/dist/upload/index.d.ts +15 -0
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +42 -49
- package/dist/upload/transactions/Transactions.js +38 -20
- package/dist/useTheme.js +22 -0
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +156 -61
- package/dist/wizard/index.d.ts +18 -0
- package/package.json +26 -14
- package/test/AccordionGroup.test.js +125 -0
- package/test/Date.test.js +15 -13
- package/test/DateInput.test.js +242 -0
- package/test/Dropdown.test.js +19 -4
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +2 -7
- package/test/Header.test.js +5 -10
- package/test/Heading.test.js +60 -12
- package/test/InputText.test.js +31 -28
- package/test/Link.test.js +25 -7
- package/test/NumberInput.test.js +259 -0
- package/test/Paginator.test.js +76 -60
- package/test/PasswordInput.test.js +83 -0
- package/test/ResultsetTable.test.js +65 -17
- package/test/Select.test.js +869 -132
- package/test/Sidenav.test.js +22 -64
- package/test/Slider.test.js +24 -15
- package/test/Spinner.test.js +5 -0
- package/test/Tabs.test.js +21 -0
- package/test/TextInput.test.js +731 -0
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +85 -0
- package/test/Upload.test.js +1 -1
- package/test/V3Select.test.js +212 -0
- package/test/{TextArea.test.js → V3TextArea.test.js} +6 -7
- package/dist/accordion/Accordion.stories.js +0 -207
- package/dist/accordion/readme.md +0 -96
- package/dist/alert/Alert.stories.js +0 -158
- package/dist/alert/close.svg +0 -4
- package/dist/alert/error.svg +0 -4
- package/dist/alert/info.svg +0 -4
- package/dist/alert/readme.md +0 -43
- package/dist/alert/success.svg +0 -4
- package/dist/alert/warning.svg +0 -4
- package/dist/button/readme.md +0 -93
- package/dist/checkbox/Checkbox.stories.js +0 -144
- package/dist/checkbox/readme.md +0 -116
- package/dist/common/services/example-service.js +0 -10
- package/dist/common/services/example-service.test.js +0 -12
- package/dist/date/Date.stories.js +0 -205
- package/dist/date/calendar.svg +0 -1
- package/dist/date/calendar_dark.svg +0 -1
- package/dist/date/readme.md +0 -73
- package/dist/dialog/Dialog.stories.js +0 -217
- package/dist/dialog/readme.md +0 -32
- package/dist/dropdown/Dropdown.stories.js +0 -249
- package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
- package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
- package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
- package/dist/dropdown/readme.md +0 -69
- package/dist/footer/Footer.stories.js +0 -94
- package/dist/footer/dxc_logo_wht.png +0 -0
- package/dist/footer/readme.md +0 -41
- package/dist/header/Header.stories.js +0 -176
- package/dist/header/close_icon.svg +0 -1
- package/dist/header/dxc_logo_black.png +0 -0
- package/dist/header/dxc_logo_white.png +0 -0
- package/dist/header/hamb_menu_black.svg +0 -1
- package/dist/header/hamb_menu_white.svg +0 -1
- package/dist/header/readme.md +0 -33
- package/dist/input-text/InputText.stories.js +0 -209
- package/dist/input-text/error.svg +0 -1
- package/dist/input-text/readme.md +0 -91
- package/dist/link/readme.md +0 -51
- package/dist/paginator/images/next.svg +0 -3
- package/dist/paginator/images/nextPage.svg +0 -3
- package/dist/paginator/images/previous.svg +0 -3
- package/dist/paginator/images/previousPage.svg +0 -3
- package/dist/paginator/readme.md +0 -50
- package/dist/progress-bar/ProgressBar.stories.js +0 -280
- package/dist/progress-bar/readme.md +0 -63
- package/dist/radio/Radio.stories.js +0 -166
- package/dist/radio/readme.md +0 -70
- package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
- package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
- package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
- package/dist/select/Select.stories.js +0 -235
- package/dist/select/readme.md +0 -72
- package/dist/sidenav/arrow_icon.svg +0 -3
- package/dist/slider/Slider.stories.js +0 -241
- package/dist/slider/readme.md +0 -64
- package/dist/spinner/Spinner.stories.js +0 -183
- package/dist/spinner/readme.md +0 -65
- package/dist/switch/Switch.stories.js +0 -134
- package/dist/switch/readme.md +0 -133
- package/dist/tabs/Tabs.stories.js +0 -130
- package/dist/tabs/readme.md +0 -78
- package/dist/tabs-for-sections/TabsForSections.js +0 -107
- package/dist/tabs-for-sections/readme.md +0 -78
- package/dist/toggle/Toggle.stories.js +0 -297
- package/dist/toggle/readme.md +0 -80
- package/dist/upload/Upload.stories.js +0 -72
- package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
- package/dist/upload/buttons-upload/upload-button.svg +0 -1
- package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
- package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
- package/dist/upload/file-upload/audio-icon.svg +0 -4
- package/dist/upload/file-upload/close.svg +0 -4
- package/dist/upload/file-upload/file-icon.svg +0 -4
- package/dist/upload/file-upload/video-icon.svg +0 -4
- package/dist/upload/readme.md +0 -37
- package/dist/upload/transaction/audio-icon-err.svg +0 -4
- package/dist/upload/transaction/audio-icon.svg +0 -4
- package/dist/upload/transaction/error-icon.svg +0 -4
- package/dist/upload/transaction/file-icon-err.svg +0 -4
- package/dist/upload/transaction/file-icon.svg +0 -4
- package/dist/upload/transaction/image-icon-err.svg +0 -4
- package/dist/upload/transaction/image-icon.svg +0 -4
- package/dist/upload/transaction/success-icon.svg +0 -4
- package/dist/upload/transaction/video-icon-err.svg +0 -4
- package/dist/upload/transaction/video-icon.svg +0 -4
- package/dist/wizard/invalid_icon.svg +0 -6
- package/dist/wizard/valid_icon.svg +0 -6
- package/dist/wizard/validation-wrong.svg +0 -6
- package/test/TabsForSections.test.js +0 -34
- package/test/Toggle.test.js +0 -43
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
|
|
5
|
+
import DxcFileInput from "../src/file-input/FileInput";
|
|
6
|
+
|
|
7
|
+
describe("FileInput component tests", () => {
|
|
8
|
+
const file1 = new File(["file1"], "file1.png", { type: "image/png" });
|
|
9
|
+
const file2 = new File(["file2"], "file2.txt", {
|
|
10
|
+
type: "text/plain",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const files = [
|
|
14
|
+
{
|
|
15
|
+
error: null,
|
|
16
|
+
preview: null,
|
|
17
|
+
file: file1,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
error: "Error message",
|
|
21
|
+
preview: null,
|
|
22
|
+
file: file2,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
test("Renders with correct labels and helper text in file mode", () => {
|
|
27
|
+
const { getByText } = render(<DxcFileInput label="File input label" helperText="File input helper text" />);
|
|
28
|
+
expect(getByText("File input label")).toBeTruthy();
|
|
29
|
+
expect(getByText("File input helper text")).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
test("Renders with correct button label in file mode", () => {
|
|
32
|
+
const { getByText } = render(<DxcFileInput label="File input label" helperText="File input helper text" />);
|
|
33
|
+
expect(getByText("Select files")).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
test("Renders with correct labels in filedrop mode", () => {
|
|
36
|
+
const { getByText } = render(
|
|
37
|
+
<DxcFileInput label="File input label" helperText="File input helper text" mode="filedrop" />
|
|
38
|
+
);
|
|
39
|
+
expect(getByText("Select")).toBeTruthy();
|
|
40
|
+
expect(getByText("or drop files")).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
test("Renders with correct labels in dropzone mode", () => {
|
|
43
|
+
const { getByText } = render(
|
|
44
|
+
<DxcFileInput label="File input label" helperText="File input helper text" mode="dropzone" />
|
|
45
|
+
);
|
|
46
|
+
expect(getByText("Select")).toBeTruthy();
|
|
47
|
+
expect(getByText("or drop files")).toBeTruthy();
|
|
48
|
+
});
|
|
49
|
+
test("Disabled file input", () => {
|
|
50
|
+
const { getByText, getByRole } = render(
|
|
51
|
+
<DxcFileInput label="File input label" helperText="File input helper text" disabled />
|
|
52
|
+
);
|
|
53
|
+
expect(getByText("Select files")).toBeTruthy();
|
|
54
|
+
const button = getByRole("button");
|
|
55
|
+
expect(button.disabled).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
test("Renders file items passed in value when multiple file input", () => {
|
|
58
|
+
const callbackFile = jest.fn();
|
|
59
|
+
const { getByText } = render(
|
|
60
|
+
<DxcFileInput
|
|
61
|
+
label="File input label"
|
|
62
|
+
helperText="File input helper text"
|
|
63
|
+
value={files}
|
|
64
|
+
callbackFile={callbackFile}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
68
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
69
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
test("Renders file items when single file input", () => {
|
|
72
|
+
const callbackFile = jest.fn();
|
|
73
|
+
const { getByText } = render(
|
|
74
|
+
<DxcFileInput
|
|
75
|
+
label="File input label"
|
|
76
|
+
helperText="File input helper text"
|
|
77
|
+
multiple={false}
|
|
78
|
+
value={files}
|
|
79
|
+
callbackFile={callbackFile}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
83
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
84
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
test("Add file item when single file input", async () => {
|
|
87
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
88
|
+
const callbackFile = jest.fn();
|
|
89
|
+
const { getByText, getByLabelText } = render(
|
|
90
|
+
<DxcFileInput
|
|
91
|
+
label="File input label"
|
|
92
|
+
helperText="File input helper text"
|
|
93
|
+
value={files}
|
|
94
|
+
callbackFile={callbackFile}
|
|
95
|
+
multiple={false}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
99
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
100
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
101
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
102
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
103
|
+
await waitFor(() => {
|
|
104
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
105
|
+
{
|
|
106
|
+
error: undefined,
|
|
107
|
+
file: newFile,
|
|
108
|
+
preview: (
|
|
109
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
110
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
111
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
112
|
+
</svg>
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
test("Renders file items and delete one file", async () => {
|
|
119
|
+
const callbackFile = jest.fn();
|
|
120
|
+
const { getByText, getAllByRole } = render(
|
|
121
|
+
<DxcFileInput
|
|
122
|
+
label="File input label"
|
|
123
|
+
helperText="File input helper text"
|
|
124
|
+
value={files}
|
|
125
|
+
callbackFile={callbackFile}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
expect(getByText("file1.png")).toBeTruthy();
|
|
129
|
+
expect(getByText("file2.txt")).toBeTruthy();
|
|
130
|
+
expect(getByText("Error message")).toBeTruthy();
|
|
131
|
+
const removeBtn = getAllByRole("button")[1];
|
|
132
|
+
userEvent.click(removeBtn);
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(callbackFile).toHaveBeenCalledWith([{ error: "Error message", file: file2, preview: null }]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("CallbackFile is correctly called", async () => {
|
|
139
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
140
|
+
const callbackFile = jest.fn();
|
|
141
|
+
const { getByLabelText } = render(
|
|
142
|
+
<DxcFileInput
|
|
143
|
+
label="File input label"
|
|
144
|
+
helperText="File input helper text"
|
|
145
|
+
value={files}
|
|
146
|
+
callbackFile={callbackFile}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
150
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
151
|
+
await waitFor(() => {
|
|
152
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
153
|
+
{ error: null, preview: null, file: file1 },
|
|
154
|
+
{ error: "Error message", preview: null, file: file2 },
|
|
155
|
+
{
|
|
156
|
+
error: undefined,
|
|
157
|
+
file: newFile,
|
|
158
|
+
preview: (
|
|
159
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
160
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
161
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
162
|
+
</svg>
|
|
163
|
+
),
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("Callback called correctly when a file size does not comply minSize or maxSize", async () => {
|
|
170
|
+
const newFile = new File(["newFile"], "newFile.pdf", { type: "pdf" });
|
|
171
|
+
const callbackFile = jest.fn();
|
|
172
|
+
const { getByLabelText } = render(
|
|
173
|
+
<DxcFileInput
|
|
174
|
+
label="File input label"
|
|
175
|
+
helperText="File input helper text"
|
|
176
|
+
minSize={1000}
|
|
177
|
+
maxSize={20000}
|
|
178
|
+
value={files}
|
|
179
|
+
callbackFile={callbackFile}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
const inputFile = getByLabelText("File input label", { hidden: true });
|
|
183
|
+
fireEvent.change(inputFile, { target: { files: [newFile] } });
|
|
184
|
+
await waitFor(() => {
|
|
185
|
+
expect(callbackFile).toHaveBeenCalledWith([
|
|
186
|
+
{ error: null, preview: null, file: file1 },
|
|
187
|
+
{ error: "Error message", preview: null, file: file2 },
|
|
188
|
+
{
|
|
189
|
+
error: "File size must be greater than min size.",
|
|
190
|
+
file: newFile,
|
|
191
|
+
preview: (
|
|
192
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
|
193
|
+
<path fill="none" d="M0 0h24v24H0V0z" />
|
|
194
|
+
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" />
|
|
195
|
+
</svg>
|
|
196
|
+
),
|
|
197
|
+
},
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
package/test/Footer.test.js
CHANGED
|
@@ -5,13 +5,8 @@ import icon from "../../app/src/images/linkedin.svg";
|
|
|
5
5
|
|
|
6
6
|
describe("Footer component tests", () => {
|
|
7
7
|
test("Footer renders with default logo", () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Footer renders with logo", () => {
|
|
13
|
-
const { getByRole } = render(<DxcFooter logoSrc={icon}></DxcFooter>);
|
|
14
|
-
expect(getByRole("img")).toBeTruthy();
|
|
8
|
+
const { getByTitle } = render(<DxcFooter></DxcFooter>);
|
|
9
|
+
expect(getByTitle("DXC Logo")).toBeTruthy();
|
|
15
10
|
});
|
|
16
11
|
|
|
17
12
|
test("Footer renders with social links", () => {
|
package/test/Header.test.js
CHANGED
|
@@ -5,25 +5,20 @@ import icon from "../../app/src/images/linkedin.svg";
|
|
|
5
5
|
|
|
6
6
|
describe("Header component tests", () => {
|
|
7
7
|
test("Header renders with default logo", () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Header renders with logo", () => {
|
|
13
|
-
const { getByRole } = render(<DxcHeader logoSrc={icon}></DxcHeader>);
|
|
14
|
-
expect(getByRole("img")).toBeTruthy();
|
|
8
|
+
const { getByTitle } = render(<DxcHeader></DxcHeader>);
|
|
9
|
+
expect(getByTitle("DXC Logo")).toBeTruthy();
|
|
15
10
|
});
|
|
16
11
|
|
|
17
12
|
test("Call correct function on logo click", () => {
|
|
18
13
|
const onClick = jest.fn();
|
|
19
|
-
const {
|
|
20
|
-
const logo =
|
|
14
|
+
const { getByTitle } = render(<DxcHeader onClick={onClick}></DxcHeader>);
|
|
15
|
+
const logo = getByTitle("DXC Logo");
|
|
21
16
|
fireEvent.click(logo);
|
|
22
17
|
expect(onClick).toHaveBeenCalled();
|
|
23
18
|
});
|
|
24
19
|
|
|
25
20
|
test("Header renders with correct children", () => {
|
|
26
|
-
//We need to force the offsetWidth value
|
|
21
|
+
// We need to force the offsetWidth value
|
|
27
22
|
Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 1024 });
|
|
28
23
|
|
|
29
24
|
const { getByText } = render(<DxcHeader content={<p>header-child-text</p>}></DxcHeader>);
|
package/test/Heading.test.js
CHANGED
|
@@ -3,33 +3,81 @@ import { render } from "@testing-library/react";
|
|
|
3
3
|
import DxcHeading from "../src/heading/Heading";
|
|
4
4
|
|
|
5
5
|
describe("Heading component tests", () => {
|
|
6
|
-
test("
|
|
7
|
-
const { getByText } = render(<DxcHeading text="my-heading-test"></DxcHeading>);
|
|
6
|
+
test("Heading renders with default level", () => {
|
|
7
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test"></DxcHeading>);
|
|
8
8
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
9
|
+
expect(getByRole("heading", { level: 1 })).toBeTruthy();
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
test("
|
|
12
|
-
const { getByText } = render(<DxcHeading text="my-heading-test" level={1}></DxcHeading>);
|
|
12
|
+
test("Heading renders with level 1", () => {
|
|
13
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={1}></DxcHeading>);
|
|
13
14
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
15
|
+
expect(getByRole("heading", { level: 1 })).toBeTruthy();
|
|
14
16
|
});
|
|
15
17
|
|
|
16
|
-
test("
|
|
17
|
-
const { getByText } = render(<DxcHeading text="my-heading-test" level={2}></DxcHeading>);
|
|
18
|
+
test("Heading renders with level 2", () => {
|
|
19
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={2}></DxcHeading>);
|
|
18
20
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
21
|
+
expect(getByRole("heading", { level: 2 })).toBeTruthy();
|
|
19
22
|
});
|
|
20
23
|
|
|
21
|
-
test("
|
|
22
|
-
const { getByText } = render(<DxcHeading text="my-heading-test" level={3}></DxcHeading>);
|
|
24
|
+
test("Heading renders with level 3", () => {
|
|
25
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={3}></DxcHeading>);
|
|
23
26
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
27
|
+
expect(getByRole("heading", { level: 3 })).toBeTruthy();
|
|
24
28
|
});
|
|
25
29
|
|
|
26
|
-
test("
|
|
27
|
-
const { getByText } = render(<DxcHeading text="my-heading-test" level={4}></DxcHeading>);
|
|
30
|
+
test("Heading renders with level 4", () => {
|
|
31
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={4}></DxcHeading>);
|
|
28
32
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
33
|
+
expect(getByRole("heading", { level: 4 })).toBeTruthy();
|
|
29
34
|
});
|
|
30
35
|
|
|
31
|
-
test("
|
|
32
|
-
const { getByText } = render(<DxcHeading text="my-heading-test" level={5}></DxcHeading>);
|
|
36
|
+
test("Heading renders with level 5", () => {
|
|
37
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={5}></DxcHeading>);
|
|
33
38
|
expect(getByText("my-heading-test")).toBeTruthy();
|
|
39
|
+
expect(getByRole("heading", { level: 5 })).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("Heading renders with default level and as h5", () => {
|
|
43
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" as="h5"></DxcHeading>);
|
|
44
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
45
|
+
expect(getByRole("heading", { level: 5 })).toBeTruthy();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Heading renders with level 1 and as h5", () => {
|
|
49
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={1} as="h5"></DxcHeading>);
|
|
50
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
51
|
+
expect(getByRole("heading", { level: 5 })).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("Heading renders with level 2 and as h4", () => {
|
|
55
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={2} as="h4"></DxcHeading>);
|
|
56
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
57
|
+
expect(getByRole("heading", { level: 4 })).toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("Heading renders with level 3 and as h2", () => {
|
|
61
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={3} as="h2"></DxcHeading>);
|
|
62
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
63
|
+
expect(getByRole("heading", { level: 2 })).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("Heading renders with level 4 and as h3", () => {
|
|
67
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={4} as="h3"></DxcHeading>);
|
|
68
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
69
|
+
expect(getByRole("heading", { level: 3 })).toBeTruthy();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("Heading renders with level 5 as h4", () => {
|
|
73
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={5} as="h4"></DxcHeading>);
|
|
74
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
75
|
+
expect(getByRole("heading", { level: 4 })).toBeTruthy();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("Heading renders with level 5 and invalid as", () => {
|
|
79
|
+
const { getByText, getByRole } = render(<DxcHeading text="my-heading-test" level={5} as="h4afdssf"></DxcHeading>);
|
|
80
|
+
expect(getByText("my-heading-test")).toBeTruthy();
|
|
81
|
+
expect(getByRole("heading", { level: 5 })).toBeTruthy();
|
|
34
82
|
});
|
|
35
83
|
});
|
package/test/InputText.test.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render, fireEvent, waitFor, screen, act, waitForElementToBeRemoved } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
|
|
3
5
|
import icon from "../../app/src/images/invision.svg";
|
|
4
6
|
|
|
5
|
-
import DxcInputText from "../
|
|
7
|
+
import DxcInputText from "../src/input-text/InputText";
|
|
6
8
|
|
|
7
9
|
const countries = ["Albania", "Andorra", "Armenia", "Austria", "Azerbaijan"];
|
|
8
10
|
|
|
@@ -12,12 +14,12 @@ jest.mock("popper.js", () => {
|
|
|
12
14
|
const PopperJS = jest.requireActual("popper.js");
|
|
13
15
|
|
|
14
16
|
return class {
|
|
15
|
-
static placements = PopperJS.placements;
|
|
16
|
-
|
|
17
17
|
constructor() {
|
|
18
|
+
this.placements = PopperJS.placements;
|
|
18
19
|
return {
|
|
19
20
|
destroy: () => {},
|
|
20
21
|
scheduleUpdate: () => {},
|
|
22
|
+
update: () => {},
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
};
|
|
@@ -26,7 +28,6 @@ jest.mock("popper.js", () => {
|
|
|
26
28
|
describe("InputText component tests", () => {
|
|
27
29
|
test("Input renders with correct label", () => {
|
|
28
30
|
const { getByText } = render(<DxcInputText label="Input label" />);
|
|
29
|
-
|
|
30
31
|
expect(getByText("Input label")).toBeTruthy();
|
|
31
32
|
});
|
|
32
33
|
|
|
@@ -34,7 +35,7 @@ describe("InputText component tests", () => {
|
|
|
34
35
|
const onChange = jest.fn();
|
|
35
36
|
const { getByRole } = render(<DxcInputText label="Input label" onChange={onChange} />);
|
|
36
37
|
const input = getByRole("textbox");
|
|
37
|
-
|
|
38
|
+
userEvent.type(input, "20000");
|
|
38
39
|
expect(onChange).toHaveBeenCalled();
|
|
39
40
|
expect(onChange).toHaveBeenCalledWith("20000");
|
|
40
41
|
});
|
|
@@ -44,7 +45,7 @@ describe("InputText component tests", () => {
|
|
|
44
45
|
|
|
45
46
|
const { getByRole } = render(<DxcInputText label="Input label" onChange={onChange} onBlur={onBlur} />);
|
|
46
47
|
const input = getByRole("textbox");
|
|
47
|
-
|
|
48
|
+
userEvent.type(input, "Test value");
|
|
48
49
|
fireEvent.blur(input);
|
|
49
50
|
expect(onBlur).toHaveBeenCalled();
|
|
50
51
|
expect(onBlur).toHaveBeenCalledWith("Test value");
|
|
@@ -54,7 +55,7 @@ describe("InputText component tests", () => {
|
|
|
54
55
|
const onChange = jest.fn();
|
|
55
56
|
const { getByRole } = render(<DxcInputText label="Input label" onChange={onChange} />);
|
|
56
57
|
const input = getByRole("textbox");
|
|
57
|
-
|
|
58
|
+
userEvent.type(input, "20000");
|
|
58
59
|
expect(onChange).toHaveBeenCalled();
|
|
59
60
|
expect(onChange).toHaveBeenCalledWith("20000");
|
|
60
61
|
expect(input.value).toBe("20000");
|
|
@@ -67,9 +68,8 @@ describe("InputText component tests", () => {
|
|
|
67
68
|
<DxcInputText label="Input label" value="Test value" onChange={onChange} onBlur={onBlur} />
|
|
68
69
|
);
|
|
69
70
|
const input = getByRole("textbox");
|
|
70
|
-
|
|
71
|
+
userEvent.type(input, "20000");
|
|
71
72
|
expect(onChange).toHaveBeenCalled();
|
|
72
|
-
expect(onChange).toHaveBeenCalledWith("20000");
|
|
73
73
|
expect(input.value).toBe("Test value");
|
|
74
74
|
fireEvent.blur(input);
|
|
75
75
|
expect(onBlur).toHaveBeenCalled();
|
|
@@ -79,14 +79,14 @@ describe("InputText component tests", () => {
|
|
|
79
79
|
const onClick = jest.fn();
|
|
80
80
|
const { getByRole } = render(<DxcInputText label="Input label" prefixIconSrc={icon} onClickPrefix={onClick} />);
|
|
81
81
|
const prefixIcon = getByRole("img");
|
|
82
|
-
|
|
82
|
+
userEvent.click(prefixIcon);
|
|
83
83
|
expect(onClick).toHaveBeenCalled();
|
|
84
84
|
});
|
|
85
85
|
test("Suffix icon onClick", () => {
|
|
86
86
|
const onClick = jest.fn();
|
|
87
87
|
const { getByRole } = render(<DxcInputText label="Input label" suffixIconSrc={icon} onClickSuffix={onClick} />);
|
|
88
88
|
const suffixIcon = getByRole("img");
|
|
89
|
-
|
|
89
|
+
userEvent.click(suffixIcon);
|
|
90
90
|
expect(onClick).toHaveBeenCalled();
|
|
91
91
|
});
|
|
92
92
|
});
|
|
@@ -98,9 +98,9 @@ describe("Autocomplete component Synchronous tests", () => {
|
|
|
98
98
|
<DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
|
|
99
99
|
);
|
|
100
100
|
const input = screen.getByRole("textbox");
|
|
101
|
-
|
|
101
|
+
fireEvent.focus(input);
|
|
102
102
|
expect(screen.getByText("Andorra")).toBeTruthy();
|
|
103
|
-
|
|
103
|
+
userEvent.type(input, "X");
|
|
104
104
|
expect(screen.getByText("No matches found.")).toBeTruthy();
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -110,7 +110,7 @@ describe("Autocomplete component Synchronous tests", () => {
|
|
|
110
110
|
<DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
|
|
111
111
|
);
|
|
112
112
|
const input = screen.getByRole("textbox");
|
|
113
|
-
|
|
113
|
+
fireEvent.focus(input);
|
|
114
114
|
expect(screen.getByText("Andorra")).toBeTruthy();
|
|
115
115
|
});
|
|
116
116
|
|
|
@@ -120,14 +120,14 @@ describe("Autocomplete component Synchronous tests", () => {
|
|
|
120
120
|
<DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
|
|
121
121
|
);
|
|
122
122
|
const input = screen.getByRole("textbox");
|
|
123
|
-
|
|
123
|
+
fireEvent.focus(input);
|
|
124
124
|
expect(screen.getByText("Andorra")).toBeTruthy();
|
|
125
|
-
|
|
125
|
+
userEvent.type(screen.getByRole("textbox"), "Alb");
|
|
126
126
|
expect(onChangeAtocomplete).toHaveBeenCalled();
|
|
127
127
|
expect(screen.getByText("Albania")).toBeTruthy();
|
|
128
128
|
const suggestion1 = screen.getByText("Albania");
|
|
129
129
|
act(() => {
|
|
130
|
-
|
|
130
|
+
userEvent.click(suggestion1);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
// expect(onChangeAtocomplete).toHaveBeenCalledWith("Albania");
|
|
@@ -144,19 +144,20 @@ describe("Autocomplete component Synchronous tests", () => {
|
|
|
144
144
|
onChange={onChangeAtocomplete}
|
|
145
145
|
/>
|
|
146
146
|
);
|
|
147
|
-
screen.getByRole("textbox")
|
|
148
|
-
|
|
147
|
+
const input = screen.getByRole("textbox");
|
|
148
|
+
fireEvent.focus(input);
|
|
149
149
|
expect(screen.getByText("Andorra")).toBeTruthy();
|
|
150
150
|
|
|
151
151
|
expect(screen.getByText("Andorra")).toBeTruthy();
|
|
152
152
|
const suggestion1 = screen.getByText("Andorra");
|
|
153
153
|
act(() => {
|
|
154
|
-
|
|
154
|
+
userEvent.click(suggestion1);
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
expect(onChangeAtocomplete).toHaveBeenCalledWith("Andorra");
|
|
158
158
|
});
|
|
159
159
|
});
|
|
160
|
+
|
|
160
161
|
describe("InputText component Asynchronous Autocomplete tests", () => {
|
|
161
162
|
test("Autocomplete Searching is shown", async () => {
|
|
162
163
|
const callbackFunc = jest.fn(() => new Promise((resolve) => setTimeout(resolve(["Italy", "Spain"]), 1000)));
|
|
@@ -166,7 +167,7 @@ describe("InputText component Asynchronous Autocomplete tests", () => {
|
|
|
166
167
|
<DxcInputText label="Autocomplete Countries" autocompleteOptions={callbackFunc} onChange={onChangeAtocomplete} />
|
|
167
168
|
);
|
|
168
169
|
const input = screen.getByRole("textbox");
|
|
169
|
-
|
|
170
|
+
fireEvent.focus(input);
|
|
170
171
|
await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
|
|
171
172
|
expect(screen.getByText("Italy")).toBeTruthy();
|
|
172
173
|
expect(screen.getByText("Spain")).toBeTruthy();
|
|
@@ -179,18 +180,19 @@ describe("InputText component Asynchronous Autocomplete tests", () => {
|
|
|
179
180
|
<DxcInputText label="Autocomplete Countries" onChange={onChangeAtocomplete} autocompleteOptions={callbackFunc} />
|
|
180
181
|
);
|
|
181
182
|
const input = screen.getByRole("textbox");
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
fireEvent.focus(input);
|
|
184
|
+
userEvent.type(input, "And");
|
|
184
185
|
await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
|
|
185
186
|
expect(screen.getByText("Italy")).toBeTruthy();
|
|
186
187
|
expect(screen.getByText("Spain")).toBeTruthy();
|
|
187
188
|
const suggestion1 = screen.getByText("Spain");
|
|
188
189
|
act(() => {
|
|
189
|
-
|
|
190
|
+
userEvent.click(suggestion1);
|
|
190
191
|
});
|
|
191
192
|
expect(onChangeAtocomplete).toHaveBeenCalledWith("Spain");
|
|
192
193
|
expect(screen.getByRole("textbox").value).toBe("Spain");
|
|
193
194
|
});
|
|
195
|
+
|
|
194
196
|
test("Asynchronous CONTROLLED autocomplete tests", async () => {
|
|
195
197
|
const callbackFunc = jest.fn(() => new Promise((resolve) => setTimeout(resolve(["Italy", "Spain"]), 3000)));
|
|
196
198
|
const onChangeAtocomplete = jest.fn();
|
|
@@ -203,18 +205,19 @@ describe("InputText component Asynchronous Autocomplete tests", () => {
|
|
|
203
205
|
/>
|
|
204
206
|
);
|
|
205
207
|
const input = screen.getByRole("textbox");
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
fireEvent.focus(input);
|
|
209
|
+
userEvent.type(input, "And");
|
|
208
210
|
await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
|
|
209
211
|
expect(screen.getByText("Italy")).toBeTruthy();
|
|
210
212
|
expect(screen.getByText("Spain")).toBeTruthy();
|
|
211
213
|
const suggestion1 = screen.getByText("Spain");
|
|
212
214
|
act(() => {
|
|
213
|
-
|
|
215
|
+
userEvent.click(suggestion1);
|
|
214
216
|
});
|
|
215
217
|
expect(onChangeAtocomplete).toHaveBeenCalledWith("Spain");
|
|
216
218
|
expect(screen.getByRole("textbox").value).toBe("test value");
|
|
217
219
|
});
|
|
220
|
+
|
|
218
221
|
test("Asynchronous autocomplete request failed", async () => {
|
|
219
222
|
const errorCallbackFunc = jest.fn(() => new Promise((resolve, reject) => setTimeout(reject("E"), 3000)));
|
|
220
223
|
const onChangeAtocomplete = jest.fn();
|
|
@@ -229,7 +232,7 @@ describe("InputText component Asynchronous Autocomplete tests", () => {
|
|
|
229
232
|
);
|
|
230
233
|
|
|
231
234
|
const input = screen.getByRole("textbox");
|
|
232
|
-
|
|
235
|
+
fireEvent.focus(input);
|
|
233
236
|
await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
|
|
234
237
|
expect(screen.getByText("Error fetching data")).toBeTruthy();
|
|
235
238
|
});
|
package/test/Link.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
2
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
3
3
|
import DxcLink from "../src/link/Link";
|
|
4
4
|
|
|
5
5
|
describe("Link component tests", () => {
|
|
@@ -9,17 +9,35 @@ describe("Link component tests", () => {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
test("Link renders with correct href", () => {
|
|
12
|
-
const {
|
|
13
|
-
expect(
|
|
12
|
+
const { getByRole } = render(<DxcLink text="Link" href="/testPage" />);
|
|
13
|
+
expect(getByRole("link").getAttribute("href")).toEqual("/testPage");
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
test("Link renders with
|
|
16
|
+
test("Link renders with correct disabled state", () => {
|
|
17
17
|
const { getByText } = render(<DxcLink text="Link" href="/testPage" disabled={true} />);
|
|
18
|
-
expect(getByText("Link").hasAttribute("
|
|
18
|
+
expect(getByText("Link").hasAttribute("href")).toBeFalsy();
|
|
19
|
+
const { getByText: getByTextLinkButton } = render(<DxcLink text="LinkButton" onClick={() => console.log("Andorra")} disabled={true} />);
|
|
20
|
+
expect(getByTextLinkButton("LinkButton").hasAttribute("onclick")).toBeFalsy();
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
test("Link open new tab", () => {
|
|
22
|
-
const {
|
|
23
|
-
expect(
|
|
24
|
+
const { getByRole } = render(<DxcLink text="Link" href="/testPage" newWindow={true} />);
|
|
25
|
+
expect(getByRole("link").getAttribute("target")).toEqual("_blank");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("Link onClick called", () => {
|
|
29
|
+
const onClick = jest.fn();
|
|
30
|
+
const { getByText } = render(<DxcLink text="Link" onClick={onClick} />);
|
|
31
|
+
const link = getByText("Link");
|
|
32
|
+
fireEvent.click(link);
|
|
33
|
+
expect(onClick).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("Disabled link onClick not called", () => {
|
|
37
|
+
const onClick = jest.fn();
|
|
38
|
+
const { getByText } = render(<DxcLink text="Link" onClick={onClick} disabled={true} />);
|
|
39
|
+
const link = getByText("Link");
|
|
40
|
+
fireEvent.click(link);
|
|
41
|
+
expect(onClick).toHaveBeenCalledTimes(0);
|
|
24
42
|
});
|
|
25
43
|
});
|