@dxc-technology/halstack-react 0.0.0-0085b72
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 +66 -0
- package/babel.config.js +8 -0
- package/dist/BackgroundColorContext.js +46 -0
- package/dist/ThemeContext.js +250 -0
- 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 +353 -0
- 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 +403 -0
- package/dist/alert/index.d.ts +51 -0
- package/dist/badge/Badge.js +63 -0
- package/dist/box/Box.js +156 -0
- package/dist/box/index.d.ts +25 -0
- package/dist/button/Button.js +238 -0
- package/dist/button/index.d.ts +24 -0
- package/dist/card/Card.js +254 -0
- package/dist/card/index.d.ts +22 -0
- package/dist/checkbox/Checkbox.js +299 -0
- package/dist/checkbox/index.d.ts +24 -0
- package/dist/chip/Chip.js +265 -0
- package/dist/chip/index.d.ts +22 -0
- package/dist/common/OpenSans.css +81 -0
- package/dist/common/RequiredComponent.js +40 -0
- 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 +22 -0
- package/dist/common/variables.js +1574 -0
- package/dist/date/Date.js +379 -0
- 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 +218 -0
- package/dist/dialog/index.d.ts +18 -0
- package/dist/dropdown/Dropdown.js +544 -0
- 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 +421 -0
- package/dist/footer/Icons.js +77 -0
- package/dist/footer/index.d.ts +25 -0
- package/dist/header/Header.js +470 -0
- package/dist/header/Icons.js +59 -0
- package/dist/header/index.d.ts +25 -0
- package/dist/heading/Heading.js +230 -0
- package/dist/heading/index.d.ts +17 -0
- package/dist/input-text/Icons.js +22 -0
- package/dist/input-text/InputText.js +705 -0
- 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 +237 -0
- package/dist/link/index.d.ts +23 -0
- package/dist/main.d.ts +40 -0
- package/dist/main.js +359 -0
- 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 +305 -0
- 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 +242 -0
- package/dist/progress-bar/index.d.ts +18 -0
- package/dist/radio/Radio.js +209 -0
- package/dist/radio/index.d.ts +23 -0
- package/dist/resultsetTable/ResultsetTable.js +358 -0
- package/dist/resultsetTable/index.d.ts +19 -0
- package/dist/select/Select.js +1096 -0
- package/dist/select/index.d.ts +53 -0
- package/dist/sidenav/Sidenav.js +179 -0
- package/dist/sidenav/index.d.ts +13 -0
- package/dist/slider/Slider.js +404 -0
- package/dist/slider/index.d.ts +29 -0
- package/dist/spinner/Spinner.js +381 -0
- package/dist/spinner/index.d.ts +17 -0
- package/dist/switch/Switch.js +222 -0
- package/dist/switch/index.d.ts +24 -0
- package/dist/table/Table.js +132 -0
- package/dist/table/index.d.ts +13 -0
- package/dist/tabs/Tabs.js +343 -0
- package/dist/tabs/index.d.ts +19 -0
- package/dist/tag/Tag.js +282 -0
- 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 +369 -0
- package/dist/textarea/index.d.ts +117 -0
- package/dist/toggle/Toggle.js +220 -0
- 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 +205 -0
- package/dist/upload/buttons-upload/ButtonsUpload.js +135 -0
- package/dist/upload/buttons-upload/Icons.js +40 -0
- package/dist/upload/dragAndDropArea/DragAndDropArea.js +329 -0
- package/dist/upload/dragAndDropArea/Icons.js +39 -0
- package/dist/upload/file-upload/FileToUpload.js +189 -0
- package/dist/upload/file-upload/Icons.js +66 -0
- package/dist/upload/files-upload/FilesToUpload.js +123 -0
- package/dist/upload/index.d.ts +15 -0
- package/dist/upload/transaction/Icons.js +160 -0
- package/dist/upload/transaction/Transaction.js +148 -0
- package/dist/upload/transactions/Transactions.js +138 -0
- package/dist/useTheme.js +22 -0
- package/dist/wizard/Icons.js +65 -0
- package/dist/wizard/Wizard.js +405 -0
- package/dist/wizard/index.d.ts +18 -0
- package/package.json +75 -0
- package/test/Accordion.test.js +33 -0
- package/test/AccordionGroup.test.js +125 -0
- package/test/Alert.test.js +53 -0
- package/test/Box.test.js +10 -0
- package/test/Button.test.js +18 -0
- package/test/Card.test.js +30 -0
- package/test/Checkbox.test.js +45 -0
- package/test/Chip.test.js +25 -0
- package/test/Date.test.js +395 -0
- package/test/DateInput.test.js +242 -0
- package/test/Dialog.test.js +23 -0
- package/test/Dropdown.test.js +145 -0
- package/test/FileInput.test.js +201 -0
- package/test/Footer.test.js +94 -0
- package/test/Header.test.js +34 -0
- package/test/Heading.test.js +83 -0
- package/test/InputText.test.js +240 -0
- package/test/Link.test.js +43 -0
- package/test/NumberInput.test.js +259 -0
- package/test/Paginator.test.js +181 -0
- package/test/PasswordInput.test.js +83 -0
- package/test/ProgressBar.test.js +35 -0
- package/test/Radio.test.js +37 -0
- package/test/ResultsetTable.test.js +330 -0
- package/test/Select.test.js +415 -0
- package/test/Sidenav.test.js +45 -0
- package/test/Slider.test.js +74 -0
- package/test/Spinner.test.js +32 -0
- package/test/Switch.test.js +45 -0
- package/test/Table.test.js +36 -0
- package/test/Tabs.test.js +109 -0
- package/test/Tag.test.js +32 -0
- package/test/TextInput.test.js +732 -0
- package/test/Textarea.test.js +193 -0
- package/test/ToggleGroup.test.js +85 -0
- package/test/Upload.test.js +60 -0
- package/test/V3Select.test.js +212 -0
- package/test/V3TextArea.test.js +51 -0
- package/test/Wizard.test.js +130 -0
- package/test/mocks/pngMock.js +1 -0
- package/test/mocks/svgMock.js +1 -0
|
@@ -0,0 +1,330 @@
|
|
|
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")[2];
|
|
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
|
+
window.HTMLElement.prototype.scrollIntoView = () => {};
|
|
259
|
+
window.HTMLElement.prototype.scrollTo = () => {};
|
|
260
|
+
const { getByText, getAllByRole, getByRole } = render(
|
|
261
|
+
<DxcResultsetTable columns={columns} showGoToPage={true} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
262
|
+
);
|
|
263
|
+
expect(getByText("Peter")).toBeTruthy();
|
|
264
|
+
expect(getByText("Louis")).toBeTruthy();
|
|
265
|
+
expect(getByText("Lana")).toBeTruthy();
|
|
266
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
267
|
+
const goToPageSelect = getAllByRole("button")[2];
|
|
268
|
+
act(() => {
|
|
269
|
+
userEvent.click(goToPageSelect);
|
|
270
|
+
});
|
|
271
|
+
const goToPageOption = getByText("2");
|
|
272
|
+
act(() => {
|
|
273
|
+
userEvent.click(goToPageOption);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
expect(getByText("4 to 6 of 10")).toBeTruthy();
|
|
277
|
+
expect(getByText("Rick")).toBeTruthy();
|
|
278
|
+
expect(getByText("Mark")).toBeTruthy();
|
|
279
|
+
expect(getByText("Cris")).toBeTruthy();
|
|
280
|
+
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("Resultsettable going to the last page shows only one row", () => {
|
|
284
|
+
const { getByText, getAllByRole } = render(
|
|
285
|
+
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
286
|
+
);
|
|
287
|
+
const lastButton = getAllByRole("button")[3];
|
|
288
|
+
fireEvent.click(lastButton);
|
|
289
|
+
expect(getByText("10 to 10 of 10")).toBeTruthy();
|
|
290
|
+
expect(getAllByRole("row")).toHaveLength(2);
|
|
291
|
+
expect(getByText("Cosmin")).toBeTruthy();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test("Resultsettable sort rows by column", () => {
|
|
295
|
+
const component = render(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>);
|
|
296
|
+
expect(component.queryByText("Peter")).toBeTruthy();
|
|
297
|
+
fireEvent.click(component.queryByText("Name"));
|
|
298
|
+
expect(component.queryByText("Tina")).not.toBeTruthy();
|
|
299
|
+
expect(component.queryByText("Cosmin")).toBeTruthy();
|
|
300
|
+
|
|
301
|
+
fireEvent.click(component.queryByText("Name"));
|
|
302
|
+
expect(component.queryByText("Tina")).toBeTruthy();
|
|
303
|
+
expect(component.queryByText("Cosmin")).not.toBeTruthy();
|
|
304
|
+
});
|
|
305
|
+
test("Resultsettable change rows should go to first page", () => {
|
|
306
|
+
const { queryByText, rerender } = render(
|
|
307
|
+
<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
|
|
308
|
+
);
|
|
309
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
310
|
+
rerender(<DxcResultsetTable columns={columns} rows={rows2} itemsPerPage={3}></DxcResultsetTable>);
|
|
311
|
+
expect(queryByText("1 to 3 of 3")).toBeTruthy();
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
test("Resultsettable change itemsPerPage should go to first page", () => {
|
|
315
|
+
const { getAllByRole, queryByText, rerender } = render(
|
|
316
|
+
<DxcResultsetTable
|
|
317
|
+
columns={columns}
|
|
318
|
+
rows={rows}
|
|
319
|
+
itemsPerPage={3}
|
|
320
|
+
itemsPerPageOptions={[2, 3]}
|
|
321
|
+
></DxcResultsetTable>
|
|
322
|
+
);
|
|
323
|
+
const lastButton = getAllByRole("button")[3];
|
|
324
|
+
fireEvent.click(lastButton);
|
|
325
|
+
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
326
|
+
rerender(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={6}></DxcResultsetTable>);
|
|
327
|
+
expect(getAllByRole("row").length - 1).toEqual(6);
|
|
328
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
329
|
+
});
|
|
330
|
+
});
|