@dxc-technology/halstack-react 0.0.0-b1729d7 → 0.0.0-b39a2d8

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 (313) hide show
  1. package/BackgroundColorContext.js +50 -0
  2. package/ThemeContext.js +246 -0
  3. package/{dist/select/Select.js → V3Select/V3Select.js} +38 -132
  4. package/V3Select/index.d.ts +27 -0
  5. package/{dist/V3Textarea → V3Textarea}/V3Textarea.js +10 -14
  6. package/V3Textarea/index.d.ts +27 -0
  7. package/accordion/Accordion.d.ts +4 -0
  8. package/{dist/accordion → accordion}/Accordion.js +35 -130
  9. package/accordion/types.d.ts +68 -0
  10. package/accordion/types.js +5 -0
  11. package/accordion-group/AccordionGroup.d.ts +7 -0
  12. package/accordion-group/AccordionGroup.js +170 -0
  13. package/accordion-group/types.d.ts +72 -0
  14. package/accordion-group/types.js +5 -0
  15. package/alert/Alert.d.ts +4 -0
  16. package/{dist/alert → alert}/Alert.js +38 -151
  17. package/alert/Alert.stories.tsx +170 -0
  18. package/alert/types.d.ts +49 -0
  19. package/alert/types.js +5 -0
  20. package/badge/Badge.js +59 -0
  21. package/box/Box.d.ts +4 -0
  22. package/{dist/box → box}/Box.js +13 -43
  23. package/box/Box.stories.tsx +132 -0
  24. package/box/types.d.ts +43 -0
  25. package/box/types.js +5 -0
  26. package/button/Button.d.ts +4 -0
  27. package/{dist/button → button}/Button.js +23 -84
  28. package/button/Button.stories.tsx +276 -0
  29. package/button/types.d.ts +57 -0
  30. package/button/types.js +5 -0
  31. package/card/Card.d.ts +4 -0
  32. package/{dist/card → card}/Card.js +33 -123
  33. package/card/Card.stories.tsx +201 -0
  34. package/card/ice-cream.jpg +0 -0
  35. package/card/types.d.ts +67 -0
  36. package/card/types.js +5 -0
  37. package/checkbox/Checkbox.d.ts +4 -0
  38. package/{dist/checkbox → checkbox}/Checkbox.js +16 -63
  39. package/checkbox/Checkbox.stories.tsx +192 -0
  40. package/checkbox/types.d.ts +60 -0
  41. package/checkbox/types.js +5 -0
  42. package/{dist/chip → chip}/Chip.js +17 -61
  43. package/chip/Chip.stories.tsx +121 -0
  44. package/chip/index.d.ts +22 -0
  45. package/{dist/common → common}/OpenSans.css +0 -0
  46. package/{dist/common → common}/RequiredComponent.js +3 -11
  47. package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
  48. package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
  49. package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
  50. package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  51. package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
  52. package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
  53. package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
  54. package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
  55. package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
  56. package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  57. package/{dist/common → common}/utils.js +0 -0
  58. package/{dist/common → common}/variables.js +160 -152
  59. package/{dist/date → date}/Date.js +21 -27
  60. package/date/index.d.ts +27 -0
  61. package/date-input/DateInput.d.ts +4 -0
  62. package/{dist/date-input → date-input}/DateInput.js +22 -61
  63. package/date-input/DateInput.stories.tsx +138 -0
  64. package/date-input/types.d.ts +100 -0
  65. package/date-input/types.js +5 -0
  66. package/dialog/Dialog.d.ts +4 -0
  67. package/{dist/dialog → dialog}/Dialog.js +20 -73
  68. package/dialog/Dialog.stories.tsx +212 -0
  69. package/dialog/types.d.ts +43 -0
  70. package/dialog/types.js +5 -0
  71. package/dropdown/Dropdown.d.ts +4 -0
  72. package/{dist/dropdown → dropdown}/Dropdown.js +44 -171
  73. package/dropdown/types.d.ts +89 -0
  74. package/dropdown/types.js +5 -0
  75. package/file-input/FileInput.d.ts +4 -0
  76. package/{dist/file-input → file-input}/FileInput.js +56 -189
  77. package/file-input/FileItem.d.ts +14 -0
  78. package/file-input/FileItem.js +182 -0
  79. package/file-input/types.d.ts +87 -0
  80. package/file-input/types.js +5 -0
  81. package/footer/Footer.d.ts +4 -0
  82. package/{dist/footer → footer}/Footer.js +38 -193
  83. package/footer/Footer.stories.jsx +151 -0
  84. package/{dist/footer → footer}/Icons.js +13 -13
  85. package/footer/types.d.ts +61 -0
  86. package/footer/types.js +5 -0
  87. package/header/Header.d.ts +7 -0
  88. package/header/Header.js +324 -0
  89. package/header/Header.stories.tsx +162 -0
  90. package/{dist/header → header}/Icons.js +7 -32
  91. package/header/types.d.ts +47 -0
  92. package/header/types.js +5 -0
  93. package/heading/Heading.d.ts +4 -0
  94. package/{dist/heading → heading}/Heading.js +30 -89
  95. package/heading/types.d.ts +33 -0
  96. package/heading/types.js +5 -0
  97. package/{dist/input-text → input-text}/Icons.js +2 -2
  98. package/{dist/input-text → input-text}/InputText.js +36 -130
  99. package/input-text/index.d.ts +36 -0
  100. package/{dist/layout → layout}/ApplicationLayout.js +31 -123
  101. package/{dist/layout → layout}/Icons.js +7 -7
  102. package/link/Link.d.ts +3 -0
  103. package/{dist/link → link}/Link.js +18 -94
  104. package/link/Link.stories.tsx +146 -0
  105. package/link/types.d.ts +74 -0
  106. package/link/types.js +5 -0
  107. package/main.d.ts +44 -0
  108. package/{dist/main.js → main.js} +93 -97
  109. package/number-input/NumberInput.d.ts +4 -0
  110. package/number-input/NumberInput.js +86 -0
  111. package/number-input/NumberInput.stories.tsx +115 -0
  112. package/{dist/number-input → number-input}/NumberInputContext.js +1 -1
  113. package/number-input/types.d.ts +117 -0
  114. package/number-input/types.js +5 -0
  115. package/package.json +32 -25
  116. package/{dist/paginator → paginator}/Icons.js +9 -9
  117. package/paginator/Paginator.d.ts +4 -0
  118. package/paginator/Paginator.js +198 -0
  119. package/paginator/Paginator.stories.tsx +63 -0
  120. package/paginator/types.d.ts +38 -0
  121. package/paginator/types.js +5 -0
  122. package/password-input/PasswordInput.d.ts +4 -0
  123. package/{dist/password-input → password-input}/PasswordInput.js +24 -60
  124. package/password-input/PasswordInput.stories.tsx +131 -0
  125. package/password-input/types.d.ts +100 -0
  126. package/password-input/types.js +5 -0
  127. package/progress-bar/ProgressBar.d.ts +4 -0
  128. package/{dist/progress-bar → progress-bar}/ProgressBar.js +20 -92
  129. package/progress-bar/ProgressBar.stories.jsx +58 -0
  130. package/progress-bar/types.d.ts +37 -0
  131. package/progress-bar/types.js +5 -0
  132. package/radio/Radio.d.ts +4 -0
  133. package/{dist/radio → radio}/Radio.js +15 -50
  134. package/radio/Radio.stories.tsx +192 -0
  135. package/radio/types.d.ts +54 -0
  136. package/radio/types.js +5 -0
  137. package/{dist/resultsetTable → resultsetTable}/ResultsetTable.js +35 -119
  138. package/resultsetTable/index.d.ts +19 -0
  139. package/select/Select.js +865 -0
  140. package/select/Select.stories.tsx +572 -0
  141. package/select/index.d.ts +131 -0
  142. package/sidenav/Sidenav.d.ts +9 -0
  143. package/{dist/sidenav → sidenav}/Sidenav.js +19 -62
  144. package/sidenav/types.d.ts +50 -0
  145. package/sidenav/types.js +5 -0
  146. package/slider/Slider.d.ts +4 -0
  147. package/{dist/slider → slider}/Slider.js +71 -158
  148. package/slider/Slider.stories.tsx +177 -0
  149. package/slider/types.d.ts +78 -0
  150. package/slider/types.js +5 -0
  151. package/spinner/Spinner.d.ts +4 -0
  152. package/spinner/Spinner.js +250 -0
  153. package/spinner/Spinner.stories.jsx +102 -0
  154. package/spinner/types.d.ts +32 -0
  155. package/spinner/types.js +5 -0
  156. package/switch/Switch.d.ts +4 -0
  157. package/{dist/switch → switch}/Switch.js +26 -69
  158. package/switch/Switch.stories.tsx +160 -0
  159. package/switch/types.d.ts +58 -0
  160. package/switch/types.js +5 -0
  161. package/table/Table.d.ts +4 -0
  162. package/{dist/table → table}/Table.js +10 -24
  163. package/table/Table.stories.jsx +276 -0
  164. package/table/types.d.ts +21 -0
  165. package/table/types.js +5 -0
  166. package/tabs/Tabs.d.ts +4 -0
  167. package/tabs/Tabs.js +211 -0
  168. package/tabs/types.d.ts +70 -0
  169. package/tabs/types.js +5 -0
  170. package/tag/Tag.d.ts +4 -0
  171. package/tag/Tag.js +193 -0
  172. package/tag/Tag.stories.tsx +145 -0
  173. package/tag/types.d.ts +60 -0
  174. package/tag/types.js +5 -0
  175. package/{dist/text-input → text-input}/TextInput.js +244 -390
  176. package/{dist/text-input → text-input}/index.d.ts +2 -2
  177. package/{dist/textarea → textarea}/Textarea.js +20 -72
  178. package/textarea/Textarea.stories.jsx +135 -0
  179. package/{dist/textarea → textarea}/index.d.ts +0 -0
  180. package/{dist/toggle → toggle}/Toggle.js +15 -49
  181. package/toggle/index.d.ts +21 -0
  182. package/{dist/toggle-group → toggle-group}/ToggleGroup.js +23 -107
  183. package/toggle-group/ToggleGroup.stories.tsx +178 -0
  184. package/toggle-group/index.d.ts +21 -0
  185. package/{dist/upload → upload}/Upload.js +14 -18
  186. package/upload/buttons-upload/ButtonsUpload.js +111 -0
  187. package/upload/buttons-upload/Icons.js +40 -0
  188. package/upload/dragAndDropArea/DragAndDropArea.js +225 -0
  189. package/upload/dragAndDropArea/Icons.js +39 -0
  190. package/upload/file-upload/FileToUpload.js +115 -0
  191. package/upload/file-upload/Icons.js +66 -0
  192. package/{dist/upload → upload}/files-upload/FilesToUpload.js +12 -26
  193. package/upload/index.d.ts +15 -0
  194. package/upload/transaction/Icons.js +160 -0
  195. package/upload/transaction/Transaction.js +104 -0
  196. package/upload/transactions/Transactions.js +94 -0
  197. package/{dist/useTheme.js → useTheme.js} +0 -0
  198. package/wizard/Icons.js +65 -0
  199. package/wizard/Wizard.d.ts +4 -0
  200. package/{dist/wizard → wizard}/Wizard.js +33 -213
  201. package/wizard/Wizard.stories.jsx +224 -0
  202. package/wizard/types.d.ts +64 -0
  203. package/wizard/types.js +5 -0
  204. package/README.md +0 -66
  205. package/babel.config.js +0 -8
  206. package/dist/BackgroundColorContext.js +0 -46
  207. package/dist/ThemeContext.js +0 -248
  208. package/dist/accordion-group/AccordionGroup.js +0 -186
  209. package/dist/alert/index.d.ts +0 -51
  210. package/dist/badge/Badge.js +0 -63
  211. package/dist/checkbox/Checkbox.stories.js +0 -144
  212. package/dist/checkbox/readme.md +0 -116
  213. package/dist/date/Date.stories.js +0 -205
  214. package/dist/date/readme.md +0 -73
  215. package/dist/date-input/index.d.ts +0 -95
  216. package/dist/file-input/FileItem.js +0 -280
  217. package/dist/file-input/index.d.ts +0 -81
  218. package/dist/header/Header.js +0 -434
  219. package/dist/link/readme.md +0 -51
  220. package/dist/main.d.ts +0 -8
  221. package/dist/new-select/NewSelect.js +0 -836
  222. package/dist/new-select/index.d.ts +0 -53
  223. package/dist/number-input/NumberInput.js +0 -136
  224. package/dist/number-input/index.d.ts +0 -113
  225. package/dist/paginator/Paginator.js +0 -283
  226. package/dist/password-input/index.d.ts +0 -94
  227. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  228. package/dist/progress-bar/readme.md +0 -63
  229. package/dist/radio/Radio.stories.js +0 -166
  230. package/dist/radio/readme.md +0 -70
  231. package/dist/slider/readme.md +0 -64
  232. package/dist/spinner/Spinner.js +0 -381
  233. package/dist/spinner/Spinner.stories.js +0 -183
  234. package/dist/spinner/readme.md +0 -65
  235. package/dist/switch/Switch.stories.js +0 -134
  236. package/dist/switch/readme.md +0 -133
  237. package/dist/tabs/Tabs.js +0 -343
  238. package/dist/tabs/Tabs.stories.js +0 -130
  239. package/dist/tabs/readme.md +0 -78
  240. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  241. package/dist/tabs-for-sections/readme.md +0 -78
  242. package/dist/tag/Tag.js +0 -282
  243. package/dist/toggle/Toggle.stories.js +0 -297
  244. package/dist/toggle/readme.md +0 -80
  245. package/dist/upload/Upload.stories.js +0 -72
  246. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
  247. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  248. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  249. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  250. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  251. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  252. package/dist/upload/file-upload/FileToUpload.js +0 -184
  253. package/dist/upload/file-upload/audio-icon.svg +0 -4
  254. package/dist/upload/file-upload/close.svg +0 -4
  255. package/dist/upload/file-upload/file-icon.svg +0 -4
  256. package/dist/upload/file-upload/video-icon.svg +0 -4
  257. package/dist/upload/readme.md +0 -37
  258. package/dist/upload/transaction/Transaction.js +0 -175
  259. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  260. package/dist/upload/transaction/audio-icon.svg +0 -4
  261. package/dist/upload/transaction/error-icon.svg +0 -4
  262. package/dist/upload/transaction/file-icon-err.svg +0 -4
  263. package/dist/upload/transaction/file-icon.svg +0 -4
  264. package/dist/upload/transaction/image-icon-err.svg +0 -4
  265. package/dist/upload/transaction/image-icon.svg +0 -4
  266. package/dist/upload/transaction/success-icon.svg +0 -4
  267. package/dist/upload/transaction/video-icon-err.svg +0 -4
  268. package/dist/upload/transaction/video-icon.svg +0 -4
  269. package/dist/upload/transactions/Transactions.js +0 -138
  270. package/dist/wizard/invalid_icon.svg +0 -5
  271. package/dist/wizard/valid_icon.svg +0 -5
  272. package/dist/wizard/validation-wrong.svg +0 -6
  273. package/test/Accordion.test.js +0 -33
  274. package/test/AccordionGroup.test.js +0 -125
  275. package/test/Alert.test.js +0 -53
  276. package/test/Box.test.js +0 -10
  277. package/test/Button.test.js +0 -18
  278. package/test/Card.test.js +0 -30
  279. package/test/Checkbox.test.js +0 -45
  280. package/test/Chip.test.js +0 -25
  281. package/test/Date.test.js +0 -397
  282. package/test/DateInput.test.js +0 -242
  283. package/test/Dialog.test.js +0 -23
  284. package/test/Dropdown.test.js +0 -145
  285. package/test/FileInput.test.js +0 -201
  286. package/test/Footer.test.js +0 -94
  287. package/test/Header.test.js +0 -34
  288. package/test/Heading.test.js +0 -35
  289. package/test/InputText.test.js +0 -248
  290. package/test/Link.test.js +0 -43
  291. package/test/NumberInput.test.js +0 -259
  292. package/test/Paginator.test.js +0 -177
  293. package/test/PasswordInput.test.js +0 -83
  294. package/test/ProgressBar.test.js +0 -35
  295. package/test/Radio.test.js +0 -37
  296. package/test/ResultsetTable.test.js +0 -329
  297. package/test/Select.test.js +0 -212
  298. package/test/Sidenav.test.js +0 -45
  299. package/test/Slider.test.js +0 -74
  300. package/test/Spinner.test.js +0 -32
  301. package/test/Switch.test.js +0 -45
  302. package/test/Table.test.js +0 -36
  303. package/test/Tabs.test.js +0 -109
  304. package/test/TabsForSections.test.js +0 -34
  305. package/test/Tag.test.js +0 -32
  306. package/test/TextInput.test.js +0 -732
  307. package/test/Textarea.test.js +0 -193
  308. package/test/ToggleGroup.test.js +0 -85
  309. package/test/Upload.test.js +0 -60
  310. package/test/V3TextArea.test.js +0 -51
  311. package/test/Wizard.test.js +0 -130
  312. package/test/mocks/pngMock.js +0 -1
  313. package/test/mocks/svgMock.js +0 -1
@@ -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
- });
@@ -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
- });
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react";
3
- import DxcTabsForSections from "../src/tabs-for-sections/TabsForSections";
4
-
5
- const sections = [
6
- {
7
- tabLabel: "S1",
8
- section: () => <div>test-section-1</div>,
9
- },
10
- {
11
- tabLabel: "S2",
12
- section: () => <div>test-section-2</div>,
13
- },
14
- {
15
- tabLabel: "S3",
16
- section: () => <div>test-section-3</div>,
17
- },
18
- ];
19
-
20
- describe("TabsForSections component tests", () => {
21
- test("TabsForSections renders with correct sections label", () => {
22
- const { getByText } = render(<DxcTabsForSections sections={sections}></DxcTabsForSections>);
23
- expect(getByText("S1")).toBeTruthy();
24
- expect(getByText("S2")).toBeTruthy();
25
- expect(getByText("S3")).toBeTruthy();
26
- });
27
-
28
- test("TabsForSections renders with correct sections content", () => {
29
- const { getByText } = render(<DxcTabsForSections sections={sections}></DxcTabsForSections>);
30
- expect(getByText("test-section-1")).toBeTruthy();
31
- expect(getByText("test-section-2")).toBeTruthy();
32
- expect(getByText("test-section-3")).toBeTruthy();
33
- });
34
- });
package/test/Tag.test.js DELETED
@@ -1,32 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent } from "@testing-library/react";
3
- import DxcTag from "../src/tag/Tag";
4
-
5
- describe("Tag component tests", () => {
6
- test("Tag renders with correct label", () => {
7
- const { getByText } = render(<DxcTag label="tag-test"></DxcTag>);
8
- expect(getByText("tag-test")).toBeTruthy();
9
- });
10
-
11
- test("Tag renders with correct label before", () => {
12
- const { getByText } = render(<DxcTag label="tag-test" labelPosition="before"></DxcTag>);
13
- expect(getByText("tag-test")).toBeTruthy();
14
- });
15
-
16
- test("Tag renders with correct icon", () => {
17
- const { getByRole } = render(<DxcTag label="tag-test" iconSrc="/test-icon.jpg"></DxcTag>);
18
- expect(getByRole("img").getAttribute("src")).toBe("/test-icon.jpg");
19
- });
20
-
21
- test("Tag renders with link href", () => {
22
- const { getByRole } = render(<DxcTag label="tag-test" linkHref="/test/page"></DxcTag>);
23
- expect(getByRole("link").getAttribute("href")).toBe("/test/page");
24
- });
25
-
26
- test("Call correct function on click", () => {
27
- const onClick = jest.fn();
28
- const { getByText } = render(<DxcTag label="tag-test" onClick={onClick}></DxcTag>);
29
- fireEvent.click(getByText("tag-test"));
30
- expect(onClick).toHaveBeenCalled();
31
- });
32
- });