@dxc-technology/halstack-react 0.0.0-9b341c0 → 0.0.0-9bcd585
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 +27 -47
- package/dist/index.d.mts +3914 -0
- package/dist/index.d.ts +3914 -0
- package/dist/index.js +14222 -0
- package/dist/index.mjs +14134 -0
- package/package.json +92 -64
- package/babel.config.js +0 -8
- package/dist/BackgroundColorContext.js +0 -46
- package/dist/ThemeContext.js +0 -250
- package/dist/V3Select/V3Select.js +0 -549
- package/dist/V3Select/index.d.ts +0 -27
- package/dist/V3Textarea/V3Textarea.js +0 -264
- package/dist/V3Textarea/index.d.ts +0 -27
- package/dist/accordion/Accordion.js +0 -353
- package/dist/accordion/index.d.ts +0 -28
- package/dist/accordion-group/AccordionGroup.js +0 -186
- package/dist/accordion-group/index.d.ts +0 -16
- package/dist/alert/Alert.js +0 -403
- package/dist/alert/index.d.ts +0 -51
- package/dist/badge/Badge.js +0 -63
- package/dist/box/Box.js +0 -156
- package/dist/box/index.d.ts +0 -25
- package/dist/button/Button.js +0 -238
- package/dist/button/index.d.ts +0 -24
- package/dist/card/Card.js +0 -254
- package/dist/card/index.d.ts +0 -22
- package/dist/checkbox/Checkbox.js +0 -299
- package/dist/checkbox/index.d.ts +0 -24
- package/dist/chip/Chip.js +0 -265
- package/dist/chip/index.d.ts +0 -22
- package/dist/common/OpenSans.css +0 -81
- package/dist/common/RequiredComponent.js +0 -40
- package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
- package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
- package/dist/common/fonts/OpenSans-Light.ttf +0 -0
- package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/dist/common/utils.js +0 -22
- package/dist/common/variables.js +0 -1574
- package/dist/date/Date.js +0 -379
- package/dist/date/index.d.ts +0 -27
- package/dist/date-input/DateInput.js +0 -400
- package/dist/date-input/index.d.ts +0 -95
- package/dist/dialog/Dialog.js +0 -218
- package/dist/dialog/index.d.ts +0 -18
- package/dist/dropdown/Dropdown.js +0 -544
- package/dist/dropdown/index.d.ts +0 -26
- package/dist/file-input/FileInput.js +0 -644
- package/dist/file-input/FileItem.js +0 -287
- package/dist/file-input/index.d.ts +0 -81
- package/dist/footer/Footer.js +0 -421
- package/dist/footer/Icons.js +0 -77
- package/dist/footer/index.d.ts +0 -25
- package/dist/header/Header.js +0 -470
- package/dist/header/Icons.js +0 -59
- package/dist/header/index.d.ts +0 -25
- package/dist/heading/Heading.js +0 -230
- package/dist/heading/index.d.ts +0 -17
- package/dist/input-text/Icons.js +0 -22
- package/dist/input-text/InputText.js +0 -705
- package/dist/input-text/index.d.ts +0 -36
- package/dist/layout/ApplicationLayout.js +0 -327
- package/dist/layout/Icons.js +0 -55
- package/dist/link/Link.js +0 -237
- package/dist/link/index.d.ts +0 -23
- package/dist/main.d.ts +0 -40
- package/dist/main.js +0 -359
- package/dist/number-input/NumberInput.js +0 -136
- package/dist/number-input/NumberInputContext.js +0 -16
- package/dist/number-input/index.d.ts +0 -113
- package/dist/paginator/Icons.js +0 -66
- package/dist/paginator/Paginator.js +0 -283
- package/dist/paginator/index.d.ts +0 -20
- package/dist/password-input/PasswordInput.js +0 -203
- package/dist/password-input/index.d.ts +0 -94
- package/dist/progress-bar/ProgressBar.js +0 -242
- package/dist/progress-bar/index.d.ts +0 -18
- package/dist/radio/Radio.js +0 -209
- package/dist/radio/index.d.ts +0 -23
- package/dist/resultsetTable/ResultsetTable.js +0 -358
- package/dist/resultsetTable/index.d.ts +0 -19
- package/dist/select/Select.js +0 -1069
- package/dist/select/index.d.ts +0 -53
- package/dist/sidenav/Sidenav.js +0 -179
- package/dist/sidenav/index.d.ts +0 -13
- package/dist/slider/Slider.js +0 -404
- package/dist/slider/index.d.ts +0 -29
- package/dist/spinner/Spinner.js +0 -381
- package/dist/spinner/index.d.ts +0 -17
- package/dist/switch/Switch.js +0 -222
- package/dist/switch/index.d.ts +0 -24
- package/dist/table/Table.js +0 -132
- package/dist/table/index.d.ts +0 -13
- package/dist/tabs/Tabs.js +0 -343
- package/dist/tabs/index.d.ts +0 -19
- package/dist/tag/Tag.js +0 -282
- package/dist/tag/index.d.ts +0 -24
- package/dist/text-input/TextInput.js +0 -974
- package/dist/text-input/index.d.ts +0 -135
- package/dist/textarea/Textarea.js +0 -369
- package/dist/textarea/index.d.ts +0 -117
- package/dist/toggle/Toggle.js +0 -220
- package/dist/toggle/index.d.ts +0 -21
- package/dist/toggle-group/ToggleGroup.js +0 -327
- package/dist/toggle-group/index.d.ts +0 -21
- package/dist/upload/Upload.js +0 -205
- package/dist/upload/buttons-upload/ButtonsUpload.js +0 -135
- package/dist/upload/buttons-upload/Icons.js +0 -40
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
- package/dist/upload/dragAndDropArea/Icons.js +0 -39
- package/dist/upload/file-upload/FileToUpload.js +0 -189
- package/dist/upload/file-upload/Icons.js +0 -66
- package/dist/upload/files-upload/FilesToUpload.js +0 -123
- package/dist/upload/index.d.ts +0 -15
- package/dist/upload/transaction/Icons.js +0 -160
- package/dist/upload/transaction/Transaction.js +0 -148
- package/dist/upload/transactions/Transactions.js +0 -138
- package/dist/useTheme.js +0 -22
- package/dist/wizard/Icons.js +0 -65
- package/dist/wizard/Wizard.js +0 -405
- package/dist/wizard/index.d.ts +0 -18
- package/test/Accordion.test.js +0 -33
- package/test/AccordionGroup.test.js +0 -125
- package/test/Alert.test.js +0 -53
- package/test/Box.test.js +0 -10
- package/test/Button.test.js +0 -18
- package/test/Card.test.js +0 -30
- package/test/Checkbox.test.js +0 -45
- package/test/Chip.test.js +0 -25
- package/test/Date.test.js +0 -395
- package/test/DateInput.test.js +0 -242
- package/test/Dialog.test.js +0 -23
- package/test/Dropdown.test.js +0 -145
- package/test/FileInput.test.js +0 -201
- package/test/Footer.test.js +0 -94
- package/test/Header.test.js +0 -34
- package/test/Heading.test.js +0 -83
- package/test/InputText.test.js +0 -240
- package/test/Link.test.js +0 -43
- package/test/NumberInput.test.js +0 -259
- package/test/Paginator.test.js +0 -177
- package/test/PasswordInput.test.js +0 -83
- package/test/ProgressBar.test.js +0 -35
- package/test/Radio.test.js +0 -37
- package/test/ResultsetTable.test.js +0 -329
- package/test/Sidenav.test.js +0 -45
- package/test/Slider.test.js +0 -74
- package/test/Spinner.test.js +0 -32
- package/test/Switch.test.js +0 -45
- package/test/Table.test.js +0 -36
- package/test/Tabs.test.js +0 -109
- package/test/Tag.test.js +0 -32
- package/test/TextInput.test.js +0 -732
- package/test/Textarea.test.js +0 -193
- package/test/ToggleGroup.test.js +0 -85
- package/test/Upload.test.js +0 -60
- package/test/V3Select.test.js +0 -212
- package/test/V3TextArea.test.js +0 -51
- package/test/Wizard.test.js +0 -130
- package/test/mocks/pngMock.js +0 -1
- package/test/mocks/svgMock.js +0 -1
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent, act } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
|
|
5
|
-
import DxcResultsetTable from "../src/resultsetTable/ResultsetTable";
|
|
6
|
-
|
|
7
|
-
const columns = [
|
|
8
|
-
{
|
|
9
|
-
displayValue: "Id",
|
|
10
|
-
isSortable: false,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
displayValue: "Name",
|
|
14
|
-
isSortable: true,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
displayValue: "City",
|
|
18
|
-
isSortable: false,
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const rows = [
|
|
23
|
-
[
|
|
24
|
-
{
|
|
25
|
-
displayValue: "001",
|
|
26
|
-
sortValue: "001",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
displayValue: "Peter",
|
|
30
|
-
sortValue: "Peter",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
displayValue: "Oviedo",
|
|
34
|
-
sortValue: "Oviedo",
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
{
|
|
39
|
-
displayValue: "002",
|
|
40
|
-
sortValue: "002",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
displayValue: "Louis",
|
|
44
|
-
sortValue: "Louis",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
displayValue: "Oviedo",
|
|
48
|
-
sortValue: "Oviedo",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
displayValue: "",
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
[
|
|
55
|
-
{
|
|
56
|
-
displayValue: "003",
|
|
57
|
-
sortValue: "003",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
displayValue: "Lana",
|
|
61
|
-
sortValue: "Lana",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
displayValue: "Albacete",
|
|
65
|
-
sortValue: "Albacete",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
[
|
|
69
|
-
{
|
|
70
|
-
displayValue: "004",
|
|
71
|
-
sortValue: "004",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
displayValue: "Rick",
|
|
75
|
-
sortValue: "Rick",
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
displayValue: "Albacete",
|
|
79
|
-
sortValue: "Albacete",
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
{
|
|
84
|
-
displayValue: "005",
|
|
85
|
-
sortValue: "005",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
displayValue: "Mark",
|
|
89
|
-
sortValue: "Mark",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
displayValue: "Madrid",
|
|
93
|
-
sortValue: "Madrid",
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
[
|
|
97
|
-
{
|
|
98
|
-
displayValue: "006",
|
|
99
|
-
sortValue: "006",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
displayValue: "Cris",
|
|
103
|
-
sortValue: "Cris",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
displayValue: "Barcelona",
|
|
107
|
-
sortValue: "Barcelona",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
displayValue: "",
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
{
|
|
115
|
-
displayValue: "007",
|
|
116
|
-
sortValue: "007",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
displayValue: "Susan",
|
|
120
|
-
sortValue: "Susan",
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
displayValue: "Madrid",
|
|
124
|
-
sortValue: "Madrid",
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
{
|
|
129
|
-
displayValue: "008",
|
|
130
|
-
sortValue: "008",
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
displayValue: "Tina",
|
|
134
|
-
sortValue: "Tina",
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
displayValue: "Barcelona",
|
|
138
|
-
sortValue: "Barcelona",
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
[
|
|
142
|
-
{
|
|
143
|
-
displayValue: "009",
|
|
144
|
-
sortValue: "009",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
displayValue: "Kevin",
|
|
148
|
-
sortValue: "Kevin",
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
displayValue: "Oviedo",
|
|
152
|
-
sortValue: "Oviedo",
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
displayValue: "",
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
[
|
|
159
|
-
{
|
|
160
|
-
displayValue: "010",
|
|
161
|
-
sortValue: "010",
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
displayValue: "Cosmin",
|
|
165
|
-
sortValue: "Cosmin",
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
displayValue: "Barcelona",
|
|
169
|
-
sortValue: "Barcelona",
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
displayValue: "",
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
const rows2 = [
|
|
178
|
-
[
|
|
179
|
-
{
|
|
180
|
-
displayValue: "546",
|
|
181
|
-
sortValue: "465",
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
displayValue: "OtherValue",
|
|
185
|
-
sortValue: "OtherValue",
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
displayValue: "OtherValue",
|
|
189
|
-
sortValue: "OtherValue",
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
[
|
|
193
|
-
{
|
|
194
|
-
displayValue: "978",
|
|
195
|
-
sortValue: "465",
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
displayValue: "OtherValue",
|
|
199
|
-
sortValue: "OtherValue",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
displayValue: "OtherValue",
|
|
203
|
-
sortValue: "OtherValue",
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
displayValue: "",
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
[
|
|
210
|
-
{
|
|
211
|
-
displayValue: "678",
|
|
212
|
-
sortValue: "344",
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
displayValue: "OtherValue",
|
|
216
|
-
sortValue: "OtherValue",
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
displayValue: "OtherValue",
|
|
220
|
-
sortValue: "OtherValue",
|
|
221
|
-
},
|
|
222
|
-
],
|
|
223
|
-
];
|
|
224
|
-
|
|
225
|
-
describe("ResultsetTable component tests", () => {
|
|
226
|
-
test("ResultsetTable rendered correctly", () => {
|
|
227
|
-
const { getByText } = render(
|
|
228
|
-
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
229
|
-
);
|
|
230
|
-
expect(getByText("Peter")).toBeTruthy();
|
|
231
|
-
});
|
|
232
|
-
test("Resultsettable shows as many rows as itemsPerPage", () => {
|
|
233
|
-
const { getAllByRole } = render(
|
|
234
|
-
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
235
|
-
);
|
|
236
|
-
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
test("Resultsettable shows rows on second page", () => {
|
|
240
|
-
const { getByText, getAllByRole } = render(
|
|
241
|
-
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
242
|
-
);
|
|
243
|
-
expect(getByText("Peter")).toBeTruthy();
|
|
244
|
-
expect(getByText("Louis")).toBeTruthy();
|
|
245
|
-
expect(getByText("Lana")).toBeTruthy();
|
|
246
|
-
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
247
|
-
const nextButton = getAllByRole("button")[3];
|
|
248
|
-
fireEvent.click(nextButton);
|
|
249
|
-
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
250
|
-
// expect(getByText("Page: 2 of 4")).toBeTruthy();
|
|
251
|
-
expect(getByText("Rick")).toBeTruthy();
|
|
252
|
-
expect(getByText("Mark")).toBeTruthy();
|
|
253
|
-
expect(getByText("Cris")).toBeTruthy();
|
|
254
|
-
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("Resultsettable goToPage works as expected", () => {
|
|
258
|
-
const { getByText, getAllByRole, getByRole } = render(
|
|
259
|
-
<DxcResultsetTable columns={columns} showGoToPage={true} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
260
|
-
);
|
|
261
|
-
expect(getByText("Peter")).toBeTruthy();
|
|
262
|
-
expect(getByText("Louis")).toBeTruthy();
|
|
263
|
-
expect(getByText("Lana")).toBeTruthy();
|
|
264
|
-
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
265
|
-
const goToPageSelect = getAllByRole("button")[2];
|
|
266
|
-
act(() => {
|
|
267
|
-
userEvent.click(goToPageSelect);
|
|
268
|
-
});
|
|
269
|
-
const goToPageOption = getByText("2");
|
|
270
|
-
act(() => {
|
|
271
|
-
userEvent.click(goToPageOption);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
275
|
-
expect(getByText("Rick")).toBeTruthy();
|
|
276
|
-
expect(getByText("Mark")).toBeTruthy();
|
|
277
|
-
expect(getByText("Cris")).toBeTruthy();
|
|
278
|
-
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
test("Resultsettable going to the last page shows only one row", () => {
|
|
282
|
-
const { getByText, getAllByRole } = render(
|
|
283
|
-
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
284
|
-
);
|
|
285
|
-
debugger;
|
|
286
|
-
const lastButton = getAllByRole("button")[4];
|
|
287
|
-
fireEvent.click(lastButton);
|
|
288
|
-
expect(getByText("10 to 10 of 10")).toBeTruthy();
|
|
289
|
-
expect(getAllByRole("row")).toHaveLength(2);
|
|
290
|
-
expect(getByText("Cosmin")).toBeTruthy();
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test("Resultsettable sort rows by column", () => {
|
|
294
|
-
const component = render(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>);
|
|
295
|
-
expect(component.queryByText("Peter")).toBeTruthy();
|
|
296
|
-
fireEvent.click(component.queryByText("Name"));
|
|
297
|
-
expect(component.queryByText("Tina")).not.toBeTruthy();
|
|
298
|
-
expect(component.queryByText("Cosmin")).toBeTruthy();
|
|
299
|
-
|
|
300
|
-
fireEvent.click(component.queryByText("Name"));
|
|
301
|
-
expect(component.queryByText("Tina")).toBeTruthy();
|
|
302
|
-
expect(component.queryByText("Cosmin")).not.toBeTruthy();
|
|
303
|
-
});
|
|
304
|
-
test("Resultsettable change rows should go to first page", () => {
|
|
305
|
-
const { queryByText, rerender } = render(
|
|
306
|
-
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
307
|
-
);
|
|
308
|
-
expect(queryByText("Peter")).toBeTruthy();
|
|
309
|
-
rerender(<DxcResultsetTable columns={columns} rows={rows2} itemsPerPage={3}></DxcResultsetTable>);
|
|
310
|
-
expect(queryByText("1 to 3 of 3")).toBeTruthy();
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
test("Resultsettable change itemsPerPage should go to first page", () => {
|
|
314
|
-
const { getAllByRole, queryByText, rerender } = render(
|
|
315
|
-
<DxcResultsetTable
|
|
316
|
-
columns={columns}
|
|
317
|
-
rows={rows}
|
|
318
|
-
itemsPerPage={3}
|
|
319
|
-
itemsPerPageOptions={[2, 3]}
|
|
320
|
-
></DxcResultsetTable>
|
|
321
|
-
);
|
|
322
|
-
const lastButton = getAllByRole("button")[5];
|
|
323
|
-
fireEvent.click(lastButton);
|
|
324
|
-
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
325
|
-
rerender(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={6}></DxcResultsetTable>);
|
|
326
|
-
expect(getAllByRole("row").length - 1).toEqual(6);
|
|
327
|
-
expect(queryByText("Peter")).toBeTruthy();
|
|
328
|
-
});
|
|
329
|
-
});
|
package/test/Sidenav.test.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import DxcSidenav from "../src/sidenav/Sidenav";
|
|
4
|
-
|
|
5
|
-
const navContent = <p>nav-content-test</p>;
|
|
6
|
-
|
|
7
|
-
describe("Sidenav component tests", () => {
|
|
8
|
-
test("Sidenav renders nav content", () => {
|
|
9
|
-
const { getByText } = render(<DxcSidenav>{navContent}</DxcSidenav>);
|
|
10
|
-
expect(getByText("nav-content-test")).toBeTruthy();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test("Sidenav renders nav and page content in mobile version", () => {
|
|
14
|
-
//425 is mobile width
|
|
15
|
-
Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 425 });
|
|
16
|
-
const { getByText } = render(<DxcSidenav>{navContent}</DxcSidenav>);
|
|
17
|
-
expect(getByText("nav-content-test")).toBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("Sidenav renders compound components", () => {
|
|
21
|
-
const { getByText } = render(
|
|
22
|
-
<DxcSidenav>
|
|
23
|
-
<DxcSidenav.Title>test-title</DxcSidenav.Title>
|
|
24
|
-
<DxcSidenav.Subtitle>test-subtitle</DxcSidenav.Subtitle>
|
|
25
|
-
<DxcSidenav.Link href="#">test-link</DxcSidenav.Link>
|
|
26
|
-
</DxcSidenav>
|
|
27
|
-
);
|
|
28
|
-
expect(getByText("test-title")).toBeTruthy();
|
|
29
|
-
expect(getByText("test-subtitle")).toBeTruthy();
|
|
30
|
-
expect(getByText("test-link")).toBeTruthy();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("Sidenav link onClick", () => {
|
|
34
|
-
const onClick = jest.fn();
|
|
35
|
-
const { getByText } = render(
|
|
36
|
-
<DxcSidenav>
|
|
37
|
-
<DxcSidenav.Link onClick={onClick}>test-link</DxcSidenav.Link>
|
|
38
|
-
</DxcSidenav>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const link = getByText("test-link");
|
|
42
|
-
fireEvent.click(link);
|
|
43
|
-
expect(onClick).toHaveBeenCalled();
|
|
44
|
-
});
|
|
45
|
-
});
|
package/test/Slider.test.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent, act } from "@testing-library/react";
|
|
3
|
-
import DxcSlider from "../src/slider/Slider";
|
|
4
|
-
|
|
5
|
-
describe("Slider component tests", () => {
|
|
6
|
-
test("Slider renders with correct text", () => {
|
|
7
|
-
const { getByText } = render(<DxcSlider minValue={0} maxValue={100} showLimitsValues />);
|
|
8
|
-
expect(getByText("0")).toBeTruthy();
|
|
9
|
-
expect(getByText("100")).toBeTruthy();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Calls correct function onChange in controlled slider", () => {
|
|
13
|
-
const onChange = jest.fn();
|
|
14
|
-
const { getByRole } = render(
|
|
15
|
-
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues value={13} showInput />
|
|
16
|
-
);
|
|
17
|
-
act(() => {
|
|
18
|
-
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
19
|
-
});
|
|
20
|
-
expect(onChange).toHaveBeenCalledWith(25);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("Calls correct function onChange in uncontrolled slider", () => {
|
|
24
|
-
const onChange = jest.fn();
|
|
25
|
-
const { getByRole } = render(
|
|
26
|
-
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues showInput />
|
|
27
|
-
);
|
|
28
|
-
act(() => {
|
|
29
|
-
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
30
|
-
});
|
|
31
|
-
expect(onChange).toHaveBeenCalledWith(25);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("Disabled slider have disabled input", () => {
|
|
35
|
-
const onChange = jest.fn();
|
|
36
|
-
const { getByRole } = render(
|
|
37
|
-
<DxcSlider minValue={0} maxValue={100} onChange={onChange} showLimitsValues disabled showInput value={13} />
|
|
38
|
-
);
|
|
39
|
-
act(() => {
|
|
40
|
-
fireEvent.change(getByRole("textbox"), { target: { value: 25 } });
|
|
41
|
-
});
|
|
42
|
-
expect(getByRole("textbox").hasAttribute("disabled")).toBeTruthy();
|
|
43
|
-
expect(getByRole("textbox").value).toBe("13");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("Calls correct function onDragEnd", () => {
|
|
47
|
-
const onDragEnd = jest.fn();
|
|
48
|
-
const { getByRole } = render(
|
|
49
|
-
<DxcSlider minValue={0} maxValue={100} showLimitsValues showInput onDragEnd={onDragEnd} value={25} />
|
|
50
|
-
);
|
|
51
|
-
act(() => {
|
|
52
|
-
fireEvent.mouseDown(getByRole("slider"));
|
|
53
|
-
fireEvent.mouseUp(getByRole("slider"));
|
|
54
|
-
});
|
|
55
|
-
expect(onDragEnd).toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("Calls correct function labelFormatCallback", () => {
|
|
59
|
-
const labelFormatCallback = jest.fn((x) => `${x}$`);
|
|
60
|
-
const { getByText } = render(
|
|
61
|
-
<DxcSlider
|
|
62
|
-
minValue={0}
|
|
63
|
-
maxValue={100}
|
|
64
|
-
showLimitsValues
|
|
65
|
-
showInput
|
|
66
|
-
value={25}
|
|
67
|
-
labelFormatCallback={labelFormatCallback}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
expect(getByText("0$")).toBeTruthy();
|
|
71
|
-
expect(getByText("100$")).toBeTruthy();
|
|
72
|
-
expect(labelFormatCallback).toHaveBeenCalledTimes(2);
|
|
73
|
-
});
|
|
74
|
-
});
|
package/test/Spinner.test.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import DxcSpinner from "../src/spinner/Spinner";
|
|
4
|
-
|
|
5
|
-
describe("Spinner component tests", () => {
|
|
6
|
-
test("Spinner renders with correct label", () => {
|
|
7
|
-
const { getByText } = render(<DxcSpinner label="test-loading"></DxcSpinner>);
|
|
8
|
-
expect(getByText("test-loading")).toBeTruthy();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test("Spinner shows value correctly", () => {
|
|
12
|
-
const { getByText } = render(<DxcSpinner label="test-loading" value={75} showValue></DxcSpinner>);
|
|
13
|
-
expect(getByText("75%")).toBeTruthy();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("Small spinner hides value and label correctly", () => {
|
|
17
|
-
const { queryByText } = render(<DxcSpinner mode="small" label="test-loading" value={75} showValue></DxcSpinner>);
|
|
18
|
-
expect(queryByText("test-loading")).toBeFalsy();
|
|
19
|
-
expect(queryByText("75%")).toBeFalsy();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("Overlay spinner shows value and label correctly", () => {
|
|
23
|
-
const { getByText } = render(<DxcSpinner mode="overlay" label="test-loading" value={75} showValue></DxcSpinner>);
|
|
24
|
-
expect(getByText("test-loading")).toBeTruthy();
|
|
25
|
-
expect(getByText("75%")).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("Get spinner by role", () => {
|
|
29
|
-
const { getByRole } = render(<DxcSpinner label="test-loading" value={75} showValue></DxcSpinner>);
|
|
30
|
-
expect(getByRole("progressbar")).toBeTruthy();
|
|
31
|
-
});
|
|
32
|
-
});
|
package/test/Switch.test.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import DxcSwitch from "../src/switch/Switch";
|
|
4
|
-
|
|
5
|
-
describe("Switch component tests", () => {
|
|
6
|
-
test("Switch renders with correct text", () => {
|
|
7
|
-
const onChange = jest.fn((returnedValue) => {
|
|
8
|
-
expect(returnedValue).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
|
|
12
|
-
expect(getByText("SwitchComponent")).toBeTruthy();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("Calls correct function on click", () => {
|
|
16
|
-
const onChange = jest.fn();
|
|
17
|
-
const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
|
|
18
|
-
|
|
19
|
-
fireEvent.click(getByText("SwitchComponent"));
|
|
20
|
-
expect(onChange).toHaveBeenCalled();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("Everytime the user clicks the component the onchange function is called with the correct value CONTROLLED COMPONENT", () => {
|
|
24
|
-
const onChange = jest.fn();
|
|
25
|
-
|
|
26
|
-
const { getByText } = render(<DxcSwitch label={"SwitchComponent"} checked={false} onChange={onChange} />);
|
|
27
|
-
|
|
28
|
-
fireEvent.click(getByText("SwitchComponent"));
|
|
29
|
-
fireEvent.click(getByText("SwitchComponent"));
|
|
30
|
-
expect(onChange.mock.calls[0][0]).toBe(true);
|
|
31
|
-
expect(onChange.mock.calls[1][0]).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
test("Everytime the user clicks the component the onchange function is called with the correct value UNCONTROLLED COMPONENT", () => {
|
|
36
|
-
const onChange = jest.fn();
|
|
37
|
-
|
|
38
|
-
const { getByText } = render(<DxcSwitch label={"SwitchComponent"} onChange={onChange} />);
|
|
39
|
-
|
|
40
|
-
fireEvent.click(getByText("SwitchComponent"));
|
|
41
|
-
fireEvent.click(getByText("SwitchComponent"));
|
|
42
|
-
expect(onChange.mock.calls[0][0]).toBe(true);
|
|
43
|
-
expect(onChange.mock.calls[1][0]).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
});
|
package/test/Table.test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import DxcTable from "../src/table/Table";
|
|
4
|
-
|
|
5
|
-
describe("Table component tests", () => {
|
|
6
|
-
test("Table renders with correct content", () => {
|
|
7
|
-
const { getByText } = render(
|
|
8
|
-
<DxcTable>
|
|
9
|
-
<tr>
|
|
10
|
-
<th>header-1</th>
|
|
11
|
-
<th>header-2</th>
|
|
12
|
-
<th>header-3</th>
|
|
13
|
-
</tr>
|
|
14
|
-
<tr>
|
|
15
|
-
<td>cell-1</td>
|
|
16
|
-
<td>cell-2</td>
|
|
17
|
-
<td>cell-3</td>
|
|
18
|
-
</tr>
|
|
19
|
-
<tr>
|
|
20
|
-
<td>cell-4</td>
|
|
21
|
-
<td>cell-5</td>
|
|
22
|
-
<td>cell-6</td>
|
|
23
|
-
</tr>
|
|
24
|
-
</DxcTable>
|
|
25
|
-
);
|
|
26
|
-
expect(getByText("header-1")).toBeTruthy();
|
|
27
|
-
expect(getByText("header-2")).toBeTruthy();
|
|
28
|
-
expect(getByText("header-3")).toBeTruthy();
|
|
29
|
-
expect(getByText("cell-1")).toBeTruthy();
|
|
30
|
-
expect(getByText("cell-2")).toBeTruthy();
|
|
31
|
-
expect(getByText("cell-3")).toBeTruthy();
|
|
32
|
-
expect(getByText("cell-4")).toBeTruthy();
|
|
33
|
-
expect(getByText("cell-5")).toBeTruthy();
|
|
34
|
-
expect(getByText("cell-6")).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
package/test/Tabs.test.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
3
|
-
import DxcTabs from "../src/tabs/Tabs";
|
|
4
|
-
|
|
5
|
-
const sampleTabs = [
|
|
6
|
-
{
|
|
7
|
-
label: "Tab-1",
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
label: "Tab-2",
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
label: "Tab-3",
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
const sampleTabsWithBadge = [
|
|
18
|
-
{
|
|
19
|
-
label: "Tab-1",
|
|
20
|
-
notificationNumber: "10",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
label: "Tab-2",
|
|
24
|
-
notificationNumber: "20",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
label: "Tab-3",
|
|
28
|
-
notificationNumber: "101",
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
describe("Tabs component tests", () => {
|
|
33
|
-
test("Tabs render with correct labels", () => {
|
|
34
|
-
const { getByText } = render(<DxcTabs tabs={sampleTabs}></DxcTabs>);
|
|
35
|
-
expect(getByText("Tab-1")).toBeTruthy();
|
|
36
|
-
expect(getByText("Tab-2")).toBeTruthy();
|
|
37
|
-
expect(getByText("Tab-3")).toBeTruthy();
|
|
38
|
-
});
|
|
39
|
-
test("Tabs render with correct labels and badges", () => {
|
|
40
|
-
const { getByText } = render(<DxcTabs tabs={sampleTabsWithBadge}></DxcTabs>);
|
|
41
|
-
expect(getByText("10")).toBeTruthy();
|
|
42
|
-
expect(getByText("20")).toBeTruthy();
|
|
43
|
-
expect(getByText("+99")).toBeTruthy();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("Tabs render with correct icons", () => {
|
|
47
|
-
const { getAllByRole } = render(
|
|
48
|
-
<DxcTabs
|
|
49
|
-
tabs={[
|
|
50
|
-
{
|
|
51
|
-
label: "Tab-1",
|
|
52
|
-
iconSrc: "/testIcon1.png",
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: "Tab-2",
|
|
56
|
-
iconSrc: "/testIcon2.png",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: "Tab-3",
|
|
60
|
-
iconSrc: "/testIcon3.png",
|
|
61
|
-
},
|
|
62
|
-
]}
|
|
63
|
-
></DxcTabs>
|
|
64
|
-
);
|
|
65
|
-
expect(getAllByRole("img")[0].getAttribute("src")).toBe("/testIcon1.png");
|
|
66
|
-
expect(getAllByRole("img")[1].getAttribute("src")).toBe("/testIcon2.png");
|
|
67
|
-
expect(getAllByRole("img")[2].getAttribute("src")).toBe("/testIcon3.png");
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("Tabs render with disabled tab", () => {
|
|
71
|
-
const { getAllByRole } = render(
|
|
72
|
-
<DxcTabs
|
|
73
|
-
tabs={[
|
|
74
|
-
{
|
|
75
|
-
label: "Tab-1",
|
|
76
|
-
isDisabled: true,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
label: "Tab-2",
|
|
80
|
-
},
|
|
81
|
-
]}
|
|
82
|
-
></DxcTabs>
|
|
83
|
-
);
|
|
84
|
-
expect(getAllByRole("tab")[0].hasAttribute("disabled")).toBeTruthy();
|
|
85
|
-
expect(getAllByRole("tab")[1].hasAttribute("disabled")).toBeFalsy();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("Uncontrolled tabs", () => {
|
|
89
|
-
const onTabClick = jest.fn();
|
|
90
|
-
const { getByText } = render(<DxcTabs tabs={sampleTabs} onTabClick={onTabClick}></DxcTabs>);
|
|
91
|
-
const tab1 = getByText("Tab-1");
|
|
92
|
-
const tab2 = getByText("Tab-2");
|
|
93
|
-
fireEvent.click(tab2);
|
|
94
|
-
expect(onTabClick).toHaveBeenCalledWith(1);
|
|
95
|
-
fireEvent.click(tab1);
|
|
96
|
-
expect(onTabClick).toHaveBeenCalledWith(0);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("Controlled tabs", () => {
|
|
100
|
-
const onTabClick = jest.fn();
|
|
101
|
-
const { getByText } = render(<DxcTabs tabs={sampleTabs} onTabClick={onTabClick} activeTabIndex={0}></DxcTabs>);
|
|
102
|
-
const tab2 = getByText("Tab-2");
|
|
103
|
-
const tab3 = getByText("Tab-3");
|
|
104
|
-
fireEvent.click(tab2);
|
|
105
|
-
expect(onTabClick).toHaveBeenCalledWith(1);
|
|
106
|
-
fireEvent.click(tab3);
|
|
107
|
-
expect(onTabClick).toHaveBeenCalledWith(2);
|
|
108
|
-
});
|
|
109
|
-
});
|