@dxc-technology/halstack-react 0.0.0-878c09d → 0.0.0-8c3739a

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.
Files changed (124) hide show
  1. package/README.md +1 -1
  2. package/babel.config.js +6 -2
  3. package/dist/BackgroundColorContext.js +46 -0
  4. package/dist/ThemeContext.js +235 -2
  5. package/dist/accordion/Accordion.js +152 -67
  6. package/dist/accordion-group/AccordionGroup.js +37 -10
  7. package/dist/alert/Alert.js +183 -84
  8. package/dist/alert/index.d.ts +51 -0
  9. package/dist/badge/Badge.js +23 -18
  10. package/dist/box/Box.js +31 -23
  11. package/dist/button/Button.js +61 -25
  12. package/dist/card/Card.js +72 -35
  13. package/dist/checkbox/Checkbox.js +98 -38
  14. package/dist/chip/Chip.js +97 -40
  15. package/dist/common/RequiredComponent.js +2 -8
  16. package/dist/common/utils.js +2 -22
  17. package/dist/common/variables.js +1439 -303
  18. package/dist/date/Date.js +69 -49
  19. package/dist/date-input/DateInput.js +400 -0
  20. package/dist/date-input/index.d.ts +95 -0
  21. package/dist/dialog/Dialog.js +58 -37
  22. package/dist/dropdown/Dropdown.js +176 -81
  23. package/dist/file-input/FileInput.js +644 -0
  24. package/dist/file-input/FileItem.js +280 -0
  25. package/dist/file-input/index.d.ts +81 -0
  26. package/dist/footer/Footer.js +74 -50
  27. package/dist/footer/dxc_logo.svg +15 -0
  28. package/dist/header/Header.js +93 -63
  29. package/dist/header/dxc_logo_black.svg +8 -0
  30. package/dist/heading/Heading.js +81 -16
  31. package/dist/input-text/InputText.js +250 -113
  32. package/dist/layout/ApplicationLayout.js +14 -18
  33. package/dist/link/Link.js +86 -41
  34. package/dist/main.d.ts +8 -0
  35. package/dist/main.js +74 -2
  36. package/dist/new-select/NewSelect.js +836 -0
  37. package/dist/new-select/index.d.ts +53 -0
  38. package/dist/new-textarea/NewTextarea.js +369 -0
  39. package/dist/new-textarea/index.d.ts +117 -0
  40. package/dist/number-input/NumberInput.js +136 -0
  41. package/dist/number-input/NumberInputContext.js +16 -0
  42. package/dist/number-input/index.d.ts +113 -0
  43. package/dist/paginator/Paginator.js +113 -56
  44. package/dist/password-input/PasswordInput.js +198 -0
  45. package/dist/password-input/index.d.ts +94 -0
  46. package/dist/progress-bar/ProgressBar.js +95 -38
  47. package/dist/radio/Radio.js +31 -17
  48. package/dist/resultsetTable/ResultsetTable.js +82 -65
  49. package/dist/select/Select.js +226 -150
  50. package/dist/sidenav/Sidenav.js +66 -15
  51. package/dist/slider/Slider.js +197 -69
  52. package/dist/spinner/Spinner.js +247 -59
  53. package/dist/switch/Switch.js +50 -27
  54. package/dist/table/Table.js +51 -24
  55. package/dist/tabs/Tabs.js +95 -43
  56. package/dist/tag/Tag.js +68 -35
  57. package/dist/text-input/TextInput.js +971 -0
  58. package/dist/text-input/index.d.ts +135 -0
  59. package/dist/textarea/Textarea.js +77 -40
  60. package/dist/toggle/Toggle.js +16 -19
  61. package/dist/toggle-group/ToggleGroup.js +142 -41
  62. package/dist/upload/Upload.js +13 -8
  63. package/dist/upload/buttons-upload/ButtonsUpload.js +31 -14
  64. package/dist/upload/dragAndDropArea/DragAndDropArea.js +78 -28
  65. package/dist/upload/file-upload/FileToUpload.js +50 -24
  66. package/dist/upload/files-upload/FilesToUpload.js +16 -16
  67. package/dist/upload/transaction/Transaction.js +44 -24
  68. package/dist/upload/transactions/Transactions.js +38 -20
  69. package/dist/useTheme.js +22 -0
  70. package/dist/wizard/Wizard.js +127 -47
  71. package/dist/wizard/invalid_icon.svg +4 -5
  72. package/dist/wizard/valid_icon.svg +4 -5
  73. package/package.json +8 -2
  74. package/test/AccordionGroup.test.js +16 -0
  75. package/test/Date.test.js +13 -13
  76. package/test/DateInput.test.js +242 -0
  77. package/test/Dropdown.test.js +15 -0
  78. package/test/FileInput.test.js +201 -0
  79. package/test/InputText.test.js +25 -17
  80. package/test/Link.test.js +3 -2
  81. package/test/NewTextarea.test.js +195 -0
  82. package/test/NumberInput.test.js +259 -0
  83. package/test/Paginator.test.js +40 -57
  84. package/test/PasswordInput.test.js +83 -0
  85. package/test/ResultsetTable.test.js +33 -8
  86. package/test/Select.test.js +44 -24
  87. package/test/Spinner.test.js +5 -0
  88. package/test/TextInput.test.js +732 -0
  89. package/test/ToggleGroup.test.js +5 -1
  90. package/dist/accordion/Accordion.stories.js +0 -207
  91. package/dist/accordion/readme.md +0 -96
  92. package/dist/accordion-group/AccordionGroup.stories.js +0 -207
  93. package/dist/accordion-group/readme.md +0 -70
  94. package/dist/alert/Alert.stories.js +0 -158
  95. package/dist/alert/close.svg +0 -4
  96. package/dist/alert/error.svg +0 -4
  97. package/dist/alert/info.svg +0 -4
  98. package/dist/alert/readme.md +0 -43
  99. package/dist/alert/success.svg +0 -4
  100. package/dist/alert/warning.svg +0 -4
  101. package/dist/button/Button.stories.js +0 -224
  102. package/dist/button/readme.md +0 -93
  103. package/dist/common/services/example-service.js +0 -10
  104. package/dist/common/services/example-service.test.js +0 -12
  105. package/dist/date/calendar.svg +0 -1
  106. package/dist/date/calendar_dark.svg +0 -1
  107. package/dist/dialog/Dialog.stories.js +0 -217
  108. package/dist/dialog/readme.md +0 -32
  109. package/dist/dropdown/Dropdown.stories.js +0 -249
  110. package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
  111. package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
  112. package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
  113. package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
  114. package/dist/dropdown/readme.md +0 -69
  115. package/dist/footer/Footer.stories.js +0 -94
  116. package/dist/footer/dxc_logo_wht.png +0 -0
  117. package/dist/header/dxc_logo_black.png +0 -0
  118. package/dist/header/dxc_logo_blk_rgb.svg +0 -6
  119. package/dist/header/dxc_logo_white.png +0 -0
  120. package/dist/input-text/InputText.stories.js +0 -209
  121. package/dist/select/Select.stories.js +0 -235
  122. package/dist/select/readme.md +0 -72
  123. package/dist/slider/Slider.stories.js +0 -241
  124. package/dist/toggle-group/readme.md +0 -82
@@ -40,43 +40,42 @@ describe("Paginator component tests", () => {
40
40
  expect(getByText("Page: 2 of 2")).toBeTruthy();
41
41
  });
42
42
 
43
- test("Call correct nextFunction", () => {
44
- const onClick = jest.fn();
45
- const { getByRole } = render(
46
- <DxcPaginator nextFunction={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
43
+ test("Paginator renders goToPage select", () => {
44
+ const { getByText } = render(
45
+ <DxcPaginator currentPage={2} showGoToPage={true} itemsPerPage={10} totalItems={20}></DxcPaginator>
47
46
  );
48
- const nextButton = getByRole("button");
49
- userEvent.click(nextButton);
50
- expect(onClick).toHaveBeenCalled();
47
+ expect(getByText("Go to page:")).toBeTruthy();
51
48
  });
52
49
 
53
- test("Call correct lastFunction", () => {
50
+ test("Paginator goToPage call correct function", () => {
54
51
  const onClick = jest.fn();
55
- const { getByRole } = render(
56
- <DxcPaginator lastFunction={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
52
+ const { getByText, getAllByRole, getByRole } = render(
53
+ <DxcPaginator
54
+ currentPage={1}
55
+ itemsPerPage={10}
56
+ totalItems={27}
57
+ showGoToPage={true}
58
+ onPageChange={onClick}
59
+ ></DxcPaginator>
57
60
  );
58
- const lastButton = getByRole("button");
59
- userEvent.click(lastButton);
61
+ const goToPageSelect = getAllByRole("button")[2];
62
+ act(() => {
63
+ userEvent.click(goToPageSelect);
64
+ });
65
+ const goToPageOption = getByText("2");
66
+ act(() => {
67
+ userEvent.click(goToPageOption);
68
+ });
60
69
  expect(onClick).toHaveBeenCalledWith(2);
61
70
  });
62
71
 
63
- test("Call correct prevFunction", () => {
64
- const onClick = jest.fn();
65
- const { getByRole } = render(
66
- <DxcPaginator prevFunction={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
67
- );
68
- const prevButton = getByRole("button");
69
- userEvent.click(prevButton);
70
- expect(onClick).toHaveBeenCalled();
71
- });
72
-
73
- test("Call correct firstFunction", () => {
72
+ test("Call correct goToPageFunction", () => {
74
73
  const onClick = jest.fn();
75
- const { getByRole } = render(
76
- <DxcPaginator firstFunction={onClick} currentPage={2} itemsPerPage={10} totalItems={30}></DxcPaginator>
74
+ const { getAllByRole } = render(
75
+ <DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
77
76
  );
78
- const firstButton = getByRole("button");
79
- userEvent.click(firstButton);
77
+ const nextButton = getAllByRole("button")[2];
78
+ userEvent.click(nextButton);
80
79
  expect(onClick).toHaveBeenCalled();
81
80
  });
82
81
 
@@ -104,10 +103,10 @@ describe("Paginator component tests", () => {
104
103
 
105
104
  test("Next button is disable in last page", () => {
106
105
  const onClick = jest.fn();
107
- const { getByRole } = render(
108
- <DxcPaginator nextFunction={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
106
+ const { getAllByRole } = render(
107
+ <DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
109
108
  );
110
- const nextButton = getByRole("button");
109
+ const nextButton = getAllByRole("button")[2];
111
110
  expect(nextButton.hasAttribute("disabled")).toBeTruthy();
112
111
  userEvent.click(nextButton);
113
112
  expect(onClick).toHaveBeenCalledTimes(0);
@@ -115,10 +114,10 @@ describe("Paginator component tests", () => {
115
114
 
116
115
  test("Last button is disable in last page", () => {
117
116
  const onClick = jest.fn();
118
- const { getByRole } = render(
119
- <DxcPaginator lastFunction={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
117
+ const { getAllByRole } = render(
118
+ <DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
120
119
  );
121
- const lastButton = getByRole("button");
120
+ const lastButton = getAllByRole("button")[3];
122
121
  expect(lastButton.hasAttribute("disabled")).toBeTruthy();
123
122
  userEvent.click(lastButton);
124
123
  expect(onClick).toHaveBeenCalledTimes(0);
@@ -126,10 +125,10 @@ describe("Paginator component tests", () => {
126
125
 
127
126
  test("First button is disable in first page", () => {
128
127
  const onClick = jest.fn();
129
- const { getByRole } = render(
130
- <DxcPaginator firstFunction={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
128
+ const { getAllByRole } = render(
129
+ <DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
131
130
  );
132
- const lastButton = getByRole("button");
131
+ const lastButton = getAllByRole("button")[0];
133
132
  expect(lastButton.hasAttribute("disabled")).toBeTruthy();
134
133
  userEvent.click(lastButton);
135
134
  expect(onClick).toHaveBeenCalledTimes(0);
@@ -137,10 +136,10 @@ describe("Paginator component tests", () => {
137
136
 
138
137
  test("Previous button is disable in first page", () => {
139
138
  const onClick = jest.fn();
140
- const { getByRole } = render(
141
- <DxcPaginator prevFunction={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
139
+ const { getAllByRole } = render(
140
+ <DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
142
141
  );
143
- const lastButton = getByRole("button");
142
+ const lastButton = getAllByRole("button")[1];
144
143
  expect(lastButton.hasAttribute("disabled")).toBeTruthy();
145
144
  userEvent.click(lastButton);
146
145
  expect(onClick).toHaveBeenCalledTimes(0);
@@ -149,15 +148,7 @@ describe("Paginator component tests", () => {
149
148
  test("Last and next buttons are disable in last page", () => {
150
149
  const onClick = jest.fn();
151
150
  const { getAllByRole } = render(
152
- <DxcPaginator
153
- prevFunction={onClick}
154
- firstFunction={onClick}
155
- nextFunction={onClick}
156
- lastFunction={onClick}
157
- currentPage={2}
158
- itemsPerPage={10}
159
- totalItems={20}
160
- ></DxcPaginator>
151
+ <DxcPaginator onPageChange={onClick} currentPage={2} itemsPerPage={10} totalItems={20}></DxcPaginator>
161
152
  );
162
153
  const firstButton = getAllByRole("button")[0];
163
154
  const prevButton = getAllByRole("button")[1];
@@ -172,15 +163,7 @@ describe("Paginator component tests", () => {
172
163
  test("First and previous buttons are disable in first page", () => {
173
164
  const onClick = jest.fn();
174
165
  const { getAllByRole } = render(
175
- <DxcPaginator
176
- prevFunction={onClick}
177
- firstFunction={onClick}
178
- nextFunction={onClick}
179
- lastFunction={onClick}
180
- currentPage={1}
181
- itemsPerPage={10}
182
- totalItems={20}
183
- ></DxcPaginator>
166
+ <DxcPaginator onPageChange={onClick} currentPage={1} itemsPerPage={10} totalItems={20}></DxcPaginator>
184
167
  );
185
168
  const firstButton = getAllByRole("button")[0];
186
169
  const prevButton = getAllByRole("button")[1];
@@ -0,0 +1,83 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import DxcPasswordInput from "../src/password-input/PasswordInput";
5
+
6
+ describe("Password input component tests", () => {
7
+ test("Password input renders with label", () => {
8
+ const { getByText } = render(<DxcPasswordInput label="Password input label" />);
9
+ expect(getByText("Password input label")).toBeTruthy();
10
+ });
11
+
12
+ test("Password input renders with helper text", () => {
13
+ const { getByText } = render(<DxcPasswordInput helperText="Helper text" />);
14
+ expect(getByText("Helper text")).toBeTruthy();
15
+ });
16
+
17
+ test("Password input renders error", () => {
18
+ const { getByText } = render(<DxcPasswordInput error="Error message." />);
19
+ expect(getByText("Error message.")).toBeTruthy();
20
+ });
21
+
22
+ test("onChange function is called correctly", () => {
23
+ const onChange = jest.fn();
24
+ const { getByRole } = render(<DxcPasswordInput label="Password input" onChange={onChange} />);
25
+ const passwordInput = getByRole("textbox");
26
+ userEvent.type(passwordInput, "Pa$$w0rd");
27
+ expect(onChange).toHaveBeenCalledWith({ value: "P", error: null });
28
+ expect(passwordInput.value).toBe("Pa$$w0rd");
29
+ });
30
+
31
+ test("onBlur function is called correctly", () => {
32
+ const onBlur = jest.fn();
33
+ const { getByRole } = render(<DxcPasswordInput label="Password input" onBlur={onBlur} />);
34
+ const passwordInput = getByRole("textbox");
35
+ userEvent.type(passwordInput, "Pa$$w0rd");
36
+ fireEvent.blur(passwordInput);
37
+ expect(onBlur).toHaveBeenCalledWith({ value: "Pa$$w0rd", error: null });
38
+ expect(passwordInput.value).toBe("Pa$$w0rd");
39
+ });
40
+
41
+ test("Clear password input value", () => {
42
+ const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
43
+ const passwordInput = getByRole("textbox");
44
+ userEvent.type(passwordInput, "Pa$$w0rd");
45
+ expect(passwordInput.value).toBe("Pa$$w0rd");
46
+ const clearButton = getAllByRole("button")[0];
47
+ userEvent.click(clearButton);
48
+ expect(passwordInput.value).toBe("");
49
+ });
50
+
51
+ test("Non clearable password input has no clear icon", () => {
52
+ const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" />);
53
+ const passwordInput = getByRole("textbox");
54
+ userEvent.type(passwordInput, "Pa$$w0rd");
55
+ expect(passwordInput.value).toBe("Pa$$w0rd");
56
+ const buttons = getAllByRole("button");
57
+ expect(buttons.length).toBe(1);
58
+ });
59
+
60
+ test("Show/hide password input button works correctly", () => {
61
+ const { getAllByRole, getByRole } = render(<DxcPasswordInput label="Password input" clearable />);
62
+ const passwordInput = getByRole("textbox");
63
+ userEvent.type(passwordInput, "Pa$$w0rd");
64
+ expect(passwordInput.value).toBe("Pa$$w0rd");
65
+ expect(passwordInput.type).toBe("password");
66
+ const showButton = getAllByRole("button")[1];
67
+ userEvent.click(showButton);
68
+ expect(passwordInput.type).toBe("text");
69
+ });
70
+
71
+ test("Password input has correct accesibility attributes", () => {
72
+ const { getByRole } = render(<DxcPasswordInput label="Password input" />);
73
+ const passwordInput = getByRole("textbox");
74
+ expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
75
+ expect(passwordInput.getAttribute("aria-controls")).toBeNull();
76
+ const showButton = getByRole("button");
77
+ expect(showButton.getAttribute("aria-expanded")).toBe("false");
78
+ expect(showButton.getAttribute("aria-label")).toBe("Show");
79
+ userEvent.click(showButton);
80
+ expect(showButton.getAttribute("aria-expanded")).toBe("true");
81
+ expect(showButton.getAttribute("aria-label")).toBe("Hide");
82
+ });
83
+ });
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
- import { render, fireEvent } from "@testing-library/react";
2
+ import { render, fireEvent, act } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+
3
5
  import DxcResultsetTable from "../src/resultsetTable/ResultsetTable";
4
6
 
5
7
  const columns = [
@@ -242,10 +244,34 @@ describe("ResultsetTable component tests", () => {
242
244
  expect(getByText("Louis")).toBeTruthy();
243
245
  expect(getByText("Lana")).toBeTruthy();
244
246
  expect(getAllByRole("row").length - 1).toEqual(3);
245
- const nextButton = getAllByRole("button")[2];
247
+ const nextButton = getAllByRole("button")[3];
246
248
  fireEvent.click(nextButton);
247
249
  expect(getByText("4 to 6 of 10")).toBeTruthy();
248
- expect(getByText("Page: 2 of 4")).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();
249
275
  expect(getByText("Rick")).toBeTruthy();
250
276
  expect(getByText("Mark")).toBeTruthy();
251
277
  expect(getByText("Cris")).toBeTruthy();
@@ -256,10 +282,10 @@ describe("ResultsetTable component tests", () => {
256
282
  const { getByText, getAllByRole } = render(
257
283
  <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={3}></DxcResultsetTable>
258
284
  );
259
- const lastButton = getAllByRole("button")[3];
285
+ debugger;
286
+ const lastButton = getAllByRole("button")[4];
260
287
  fireEvent.click(lastButton);
261
288
  expect(getByText("10 to 10 of 10")).toBeTruthy();
262
- expect(getByText("Page: 4 of 4")).toBeTruthy();
263
289
  expect(getAllByRole("row")).toHaveLength(2);
264
290
  expect(getByText("Cosmin")).toBeTruthy();
265
291
  });
@@ -293,12 +319,11 @@ describe("ResultsetTable component tests", () => {
293
319
  itemsPerPageOptions={[2, 3]}
294
320
  ></DxcResultsetTable>
295
321
  );
296
- const lastButton = getAllByRole("button")[4];
322
+ const lastButton = getAllByRole("button")[5];
297
323
  fireEvent.click(lastButton);
298
324
  expect(getAllByRole("row").length - 1).toEqual(1);
299
- expect(queryByText("Page: 4 of 4")).toBeTruthy();
300
325
  rerender(<DxcResultsetTable columns={columns} rows={rows} itemsPerPage={6}></DxcResultsetTable>);
301
326
  expect(getAllByRole("row").length - 1).toEqual(6);
302
- expect(queryByText("Page: 1 of 2")).toBeTruthy();
327
+ expect(queryByText("Peter")).toBeTruthy();
303
328
  });
304
329
  });
@@ -21,18 +21,43 @@ const optionsWithoutIcon = [
21
21
  const optionsWithIcons = [
22
22
  {
23
23
  value: 1,
24
- label: "Facebook",
25
- iconSrc: "/testIconFacebook",
24
+ label: "Image 1",
25
+ icon: (
26
+ <svg
27
+ data-testid="image-1"
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ height="24px"
30
+ viewBox="0 0 24 24"
31
+ width="24px"
32
+ fill="currentColor"
33
+ >
34
+ <path d="M0 0h24v24H0V0z" fill="none" />
35
+ <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" />
36
+ </svg>
37
+ ),
26
38
  },
27
39
  {
28
40
  value: 2,
29
- label: "Twitter",
30
- iconSrc: "/testIconTwitter",
31
- },
32
- {
33
- value: 3,
34
- label: "Linkedin",
35
- iconSrc: "/testIconLinkedin",
41
+ label: "Image 2",
42
+ icon: (
43
+ <svg
44
+ data-testid="image-2"
45
+ version="1.1"
46
+ x="0px"
47
+ y="0px"
48
+ width="24px"
49
+ height="24px"
50
+ viewBox="0 0 24 24"
51
+ enable-background="new 0 0 24 24"
52
+ >
53
+ <g id="Bounding_Box">
54
+ <rect fill="none" width="24" height="24" />
55
+ </g>
56
+ <g id="Master">
57
+ <path d="M19,9.3V4h-3v2.6L12,3L2,12h3v8h5v-6h4v6h5v-8h3L19,9.3z M10,10c0-1.1,0.9-2,2-2s2,0.9,2,2H10z" />
58
+ </g>
59
+ </svg>
60
+ ),
36
61
  },
37
62
  ];
38
63
 
@@ -60,29 +85,27 @@ describe("Select component tests", () => {
60
85
  });
61
86
 
62
87
  test("Select renders options with icons before", () => {
63
- const { getByRole, getAllByRole } = render(
88
+ const { getByRole, getByTestId } = render(
64
89
  <DxcSelect label="test-select-name" options={optionsWithIcons}></DxcSelect>
65
90
  );
66
91
  const select = getByRole("button");
67
92
  act(() => {
68
93
  userEvent.click(select);
69
94
  });
70
- expect(getAllByRole("img")[0].getAttribute("src")).toEqual("/testIconFacebook");
71
- expect(getAllByRole("img")[1].getAttribute("src")).toEqual("/testIconTwitter");
72
- expect(getAllByRole("img")[2].getAttribute("src")).toEqual("/testIconLinkedin");
95
+ expect(getByTestId("image-1")).toBeTruthy();
96
+ expect(getByTestId("image-2")).toBeTruthy();
73
97
  });
74
98
 
75
99
  test("Select renders options with icons after", () => {
76
- const { getByRole, getAllByRole } = render(
100
+ const { getByRole, getByTestId } = render(
77
101
  <DxcSelect label="test-select-name" options={optionsWithIcons} iconPosition="after"></DxcSelect>
78
102
  );
79
103
  const select = getByRole("button");
80
104
  act(() => {
81
105
  userEvent.click(select);
82
106
  });
83
- expect(getAllByRole("img")[0].getAttribute("src")).toEqual("/testIconFacebook");
84
- expect(getAllByRole("img")[1].getAttribute("src")).toEqual("/testIconTwitter");
85
- expect(getAllByRole("img")[2].getAttribute("src")).toEqual("/testIconLinkedin");
107
+ expect(getByTestId("image-1")).toBeTruthy();
108
+ expect(getByTestId("image-2")).toBeTruthy();
86
109
  });
87
110
 
88
111
  test("Select renders with a default value", () => {
@@ -166,25 +189,22 @@ describe("Select component tests", () => {
166
189
  act(() => {
167
190
  userEvent.click(select);
168
191
  });
169
- const option1 = getByText("Amazon");
170
- const option2 = getByText("Ebay");
171
- const option3 = getByText("Apple");
172
192
  act(() => {
173
- userEvent.click(option1);
193
+ userEvent.click(getByText("Amazon"));
174
194
  });
175
195
  expect(onChange).toHaveBeenCalledWith([1]);
176
196
  act(() => {
177
- userEvent.click(option2);
197
+ userEvent.click(getByText("Ebay"));
178
198
  });
179
199
  expect(onChange).toHaveBeenCalledWith([1, 2]);
180
200
  expect(getByText("Amazon, Ebay")).toBeTruthy();
181
201
  act(() => {
182
- userEvent.click(option3);
202
+ userEvent.click(getByText("Apple"));
183
203
  });
184
204
  expect(onChange).toHaveBeenCalledWith([1, 2, 3]);
185
205
  expect(getByText("Amazon, Ebay, Apple")).toBeTruthy();
186
206
  act(() => {
187
- userEvent.click(option1);
207
+ userEvent.click(getByText("Amazon"));
188
208
  });
189
209
  expect(onChange).toHaveBeenCalledWith([2, 3]);
190
210
  expect(getByText("Ebay, Apple")).toBeTruthy();
@@ -24,4 +24,9 @@ describe("Spinner component tests", () => {
24
24
  expect(getByText("test-loading")).toBeTruthy();
25
25
  expect(getByText("75%")).toBeTruthy();
26
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
+ });
27
32
  });