@dxc-technology/halstack-react 0.0.0-b3de035 → 0.0.0-b3e1a2f

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 (366) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +47 -0
  3. package/ThemeContext.d.ts +15 -0
  4. package/ThemeContext.js +243 -0
  5. package/{dist/V3Select → V3Select}/V3Select.js +35 -129
  6. package/{dist/V3Select → V3Select}/index.d.ts +0 -0
  7. package/{dist/V3Textarea → V3Textarea}/V3Textarea.js +12 -16
  8. package/{dist/V3Textarea → V3Textarea}/index.d.ts +0 -0
  9. package/accordion/Accordion.d.ts +4 -0
  10. package/{dist/accordion → accordion}/Accordion.js +37 -132
  11. package/accordion/Accordion.stories.tsx +307 -0
  12. package/accordion/types.d.ts +68 -0
  13. package/accordion/types.js +5 -0
  14. package/accordion-group/AccordionGroup.d.ts +7 -0
  15. package/accordion-group/AccordionGroup.js +170 -0
  16. package/accordion-group/AccordionGroup.stories.tsx +225 -0
  17. package/accordion-group/types.d.ts +72 -0
  18. package/accordion-group/types.js +5 -0
  19. package/alert/Alert.d.ts +4 -0
  20. package/{dist/alert → alert}/Alert.js +40 -153
  21. package/alert/Alert.stories.tsx +170 -0
  22. package/alert/types.d.ts +49 -0
  23. package/alert/types.js +5 -0
  24. package/badge/Badge.js +59 -0
  25. package/bleed/Bleed.d.ts +3 -0
  26. package/bleed/Bleed.js +84 -0
  27. package/bleed/Bleed.stories.tsx +342 -0
  28. package/bleed/types.d.ts +13 -0
  29. package/bleed/types.js +5 -0
  30. package/box/Box.d.ts +4 -0
  31. package/{dist/box → box}/Box.js +15 -45
  32. package/box/Box.stories.tsx +132 -0
  33. package/box/types.d.ts +43 -0
  34. package/box/types.js +5 -0
  35. package/button/Button.d.ts +4 -0
  36. package/{dist/button → button}/Button.js +26 -93
  37. package/button/Button.stories.tsx +274 -0
  38. package/button/types.d.ts +53 -0
  39. package/button/types.js +5 -0
  40. package/card/Card.d.ts +4 -0
  41. package/{dist/card → card}/Card.js +34 -124
  42. package/card/Card.stories.tsx +201 -0
  43. package/card/ice-cream.jpg +0 -0
  44. package/card/types.d.ts +67 -0
  45. package/card/types.js +5 -0
  46. package/checkbox/Checkbox.d.ts +4 -0
  47. package/{dist/checkbox → checkbox}/Checkbox.js +15 -61
  48. package/checkbox/Checkbox.stories.tsx +192 -0
  49. package/checkbox/types.d.ts +60 -0
  50. package/checkbox/types.js +5 -0
  51. package/chip/Chip.d.ts +4 -0
  52. package/{dist/chip → chip}/Chip.js +22 -88
  53. package/chip/Chip.stories.tsx +121 -0
  54. package/chip/types.d.ts +53 -0
  55. package/chip/types.js +5 -0
  56. package/{dist/common → common}/OpenSans.css +0 -0
  57. package/{dist/common → common}/RequiredComponent.js +3 -11
  58. package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
  59. package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
  60. package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
  61. package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  62. package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
  63. package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
  64. package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
  65. package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
  66. package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
  67. package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  68. package/{dist/common → common}/utils.js +0 -0
  69. package/{dist/common → common}/variables.js +126 -88
  70. package/{dist/date → date}/Date.js +17 -23
  71. package/{dist/date → date}/index.d.ts +0 -0
  72. package/date-input/DateInput.d.ts +4 -0
  73. package/{dist/date-input → date-input}/DateInput.js +32 -74
  74. package/date-input/DateInput.stories.tsx +138 -0
  75. package/date-input/types.d.ts +100 -0
  76. package/date-input/types.js +5 -0
  77. package/dialog/Dialog.d.ts +4 -0
  78. package/{dist/dialog → dialog}/Dialog.js +24 -76
  79. package/dialog/Dialog.stories.tsx +212 -0
  80. package/dialog/types.d.ts +43 -0
  81. package/dialog/types.js +5 -0
  82. package/dropdown/Dropdown.d.ts +4 -0
  83. package/{dist/dropdown → dropdown}/Dropdown.js +45 -172
  84. package/dropdown/Dropdown.stories.tsx +247 -0
  85. package/dropdown/types.d.ts +89 -0
  86. package/dropdown/types.js +5 -0
  87. package/file-input/FileInput.d.ts +4 -0
  88. package/file-input/FileInput.js +590 -0
  89. package/file-input/FileInput.stories.tsx +507 -0
  90. package/file-input/FileItem.d.ts +14 -0
  91. package/file-input/FileItem.js +184 -0
  92. package/file-input/types.d.ts +112 -0
  93. package/file-input/types.js +5 -0
  94. package/footer/Footer.d.ts +4 -0
  95. package/footer/Footer.js +260 -0
  96. package/footer/Footer.stories.tsx +130 -0
  97. package/footer/Icons.d.ts +2 -0
  98. package/{dist/footer → footer}/Icons.js +15 -15
  99. package/footer/types.d.ts +65 -0
  100. package/footer/types.js +5 -0
  101. package/header/Header.d.ts +7 -0
  102. package/{dist/header → header}/Header.js +58 -204
  103. package/header/Header.stories.tsx +162 -0
  104. package/header/Icons.d.ts +2 -0
  105. package/{dist/header → header}/Icons.js +7 -32
  106. package/header/types.d.ts +47 -0
  107. package/header/types.js +5 -0
  108. package/heading/Heading.d.ts +4 -0
  109. package/{dist/heading → heading}/Heading.js +25 -96
  110. package/heading/Heading.stories.tsx +54 -0
  111. package/heading/types.d.ts +33 -0
  112. package/heading/types.js +5 -0
  113. package/{dist/input-text → input-text}/Icons.js +2 -2
  114. package/{dist/input-text → input-text}/InputText.js +38 -132
  115. package/{dist/input-text → input-text}/index.d.ts +1 -1
  116. package/inset/Inset.d.ts +3 -0
  117. package/inset/Inset.js +84 -0
  118. package/inset/Inset.stories.tsx +229 -0
  119. package/inset/types.d.ts +13 -0
  120. package/inset/types.js +5 -0
  121. package/layout/ApplicationLayout.d.ts +10 -0
  122. package/{dist/layout → layout}/ApplicationLayout.js +39 -141
  123. package/layout/ApplicationLayout.stories.tsx +171 -0
  124. package/{dist/layout → layout}/Icons.js +7 -7
  125. package/layout/types.d.ts +57 -0
  126. package/layout/types.js +5 -0
  127. package/link/Link.d.ts +3 -0
  128. package/{dist/link → link}/Link.js +19 -95
  129. package/link/Link.stories.tsx +146 -0
  130. package/link/types.d.ts +74 -0
  131. package/link/types.js +5 -0
  132. package/list/List.d.ts +4 -0
  133. package/list/List.js +47 -0
  134. package/list/List.stories.tsx +95 -0
  135. package/list/types.d.ts +7 -0
  136. package/list/types.js +5 -0
  137. package/main.d.ts +48 -0
  138. package/{dist/main.js → main.js} +118 -82
  139. package/number-input/NumberInput.d.ts +4 -0
  140. package/number-input/NumberInput.js +83 -0
  141. package/number-input/NumberInput.stories.tsx +115 -0
  142. package/number-input/NumberInputContext.d.ts +4 -0
  143. package/{dist/number-input → number-input}/NumberInputContext.js +5 -2
  144. package/number-input/numberInputContextTypes.d.ts +19 -0
  145. package/number-input/numberInputContextTypes.js +5 -0
  146. package/number-input/types.d.ts +117 -0
  147. package/number-input/types.js +5 -0
  148. package/package.json +30 -17
  149. package/{dist/paginator → paginator}/Icons.js +9 -9
  150. package/paginator/Paginator.d.ts +4 -0
  151. package/paginator/Paginator.js +192 -0
  152. package/paginator/Paginator.stories.tsx +63 -0
  153. package/paginator/types.d.ts +38 -0
  154. package/paginator/types.js +5 -0
  155. package/password-input/PasswordInput.d.ts +4 -0
  156. package/{dist/password-input → password-input}/PasswordInput.js +37 -77
  157. package/password-input/PasswordInput.stories.tsx +131 -0
  158. package/password-input/types.d.ts +107 -0
  159. package/password-input/types.js +5 -0
  160. package/progress-bar/ProgressBar.d.ts +4 -0
  161. package/{dist/progress-bar → progress-bar}/ProgressBar.js +22 -94
  162. package/progress-bar/ProgressBar.stories.jsx +58 -0
  163. package/progress-bar/types.d.ts +37 -0
  164. package/progress-bar/types.js +5 -0
  165. package/radio/Radio.d.ts +4 -0
  166. package/{dist/radio → radio}/Radio.js +17 -52
  167. package/radio/Radio.stories.tsx +192 -0
  168. package/radio/types.d.ts +54 -0
  169. package/radio/types.js +5 -0
  170. package/radio-group/Radio.d.ts +4 -0
  171. package/radio-group/Radio.js +130 -0
  172. package/radio-group/RadioGroup.d.ts +4 -0
  173. package/radio-group/RadioGroup.js +268 -0
  174. package/radio-group/RadioGroup.stories.tsx +79 -0
  175. package/radio-group/types.d.ts +36 -0
  176. package/radio-group/types.js +5 -0
  177. package/resultsetTable/ResultsetTable.d.ts +4 -0
  178. package/{dist/resultsetTable → resultsetTable}/ResultsetTable.js +39 -146
  179. package/resultsetTable/ResultsetTable.stories.tsx +275 -0
  180. package/resultsetTable/types.d.ts +67 -0
  181. package/resultsetTable/types.js +5 -0
  182. package/row/Row.d.ts +3 -0
  183. package/row/Row.js +127 -0
  184. package/row/Row.stories.tsx +237 -0
  185. package/row/types.d.ts +10 -0
  186. package/row/types.js +5 -0
  187. package/select/Select.d.ts +4 -0
  188. package/{dist/select → select}/Select.js +271 -477
  189. package/select/Select.stories.tsx +572 -0
  190. package/select/types.d.ts +170 -0
  191. package/select/types.js +5 -0
  192. package/sidenav/Sidenav.d.ts +9 -0
  193. package/{dist/sidenav → sidenav}/Sidenav.js +21 -64
  194. package/sidenav/Sidenav.stories.tsx +182 -0
  195. package/sidenav/types.d.ts +50 -0
  196. package/sidenav/types.js +5 -0
  197. package/slider/Slider.d.ts +4 -0
  198. package/{dist/slider → slider}/Slider.js +74 -161
  199. package/slider/Slider.stories.tsx +177 -0
  200. package/slider/types.d.ts +78 -0
  201. package/slider/types.js +5 -0
  202. package/spinner/Spinner.d.ts +4 -0
  203. package/spinner/Spinner.js +250 -0
  204. package/spinner/Spinner.stories.jsx +103 -0
  205. package/spinner/types.d.ts +32 -0
  206. package/spinner/types.js +5 -0
  207. package/stack/Stack.d.ts +3 -0
  208. package/stack/Stack.js +97 -0
  209. package/stack/Stack.stories.tsx +164 -0
  210. package/stack/types.d.ts +9 -0
  211. package/stack/types.js +5 -0
  212. package/switch/Switch.d.ts +4 -0
  213. package/{dist/switch → switch}/Switch.js +28 -71
  214. package/switch/Switch.stories.tsx +160 -0
  215. package/switch/types.d.ts +58 -0
  216. package/switch/types.js +5 -0
  217. package/table/Table.d.ts +4 -0
  218. package/{dist/table → table}/Table.js +12 -26
  219. package/table/Table.stories.jsx +277 -0
  220. package/table/types.d.ts +21 -0
  221. package/table/types.js +5 -0
  222. package/tabs/Tabs.d.ts +4 -0
  223. package/tabs/Tabs.js +213 -0
  224. package/tabs/Tabs.stories.tsx +120 -0
  225. package/tabs/types.d.ts +78 -0
  226. package/tabs/types.js +5 -0
  227. package/tag/Tag.d.ts +4 -0
  228. package/tag/Tag.js +193 -0
  229. package/tag/Tag.stories.tsx +145 -0
  230. package/tag/types.d.ts +60 -0
  231. package/tag/types.js +5 -0
  232. package/text/Text.d.ts +7 -0
  233. package/text/Text.js +30 -0
  234. package/text/Text.stories.tsx +19 -0
  235. package/text-input/TextInput.d.ts +4 -0
  236. package/{dist/text-input → text-input}/TextInput.js +278 -458
  237. package/text-input/TextInput.stories.tsx +456 -0
  238. package/text-input/types.d.ts +159 -0
  239. package/text-input/types.js +5 -0
  240. package/textarea/Textarea.d.ts +4 -0
  241. package/{dist/textarea → textarea}/Textarea.js +38 -123
  242. package/textarea/Textarea.stories.jsx +136 -0
  243. package/textarea/types.d.ts +130 -0
  244. package/textarea/types.js +5 -0
  245. package/{dist/toggle → toggle}/Toggle.js +16 -50
  246. package/{dist/toggle → toggle}/index.d.ts +0 -0
  247. package/toggle-group/ToggleGroup.d.ts +4 -0
  248. package/{dist/toggle-group → toggle-group}/ToggleGroup.js +35 -148
  249. package/toggle-group/ToggleGroup.stories.tsx +173 -0
  250. package/toggle-group/types.d.ts +97 -0
  251. package/toggle-group/types.js +5 -0
  252. package/{dist/upload → upload}/Upload.js +11 -15
  253. package/upload/buttons-upload/ButtonsUpload.js +111 -0
  254. package/{dist/upload → upload}/buttons-upload/Icons.js +7 -7
  255. package/upload/dragAndDropArea/DragAndDropArea.js +225 -0
  256. package/{dist/upload → upload}/dragAndDropArea/Icons.js +6 -6
  257. package/upload/file-upload/FileToUpload.js +115 -0
  258. package/{dist/upload → upload}/file-upload/Icons.js +13 -13
  259. package/{dist/upload → upload}/files-upload/FilesToUpload.js +13 -27
  260. package/{dist/upload → upload}/index.d.ts +0 -0
  261. package/{dist/upload → upload}/transaction/Icons.js +31 -31
  262. package/upload/transaction/Transaction.js +104 -0
  263. package/upload/transactions/Transactions.js +94 -0
  264. package/useTheme.d.ts +2 -0
  265. package/{dist/useTheme.js → useTheme.js} +1 -1
  266. package/wizard/Wizard.d.ts +4 -0
  267. package/wizard/Wizard.js +281 -0
  268. package/wizard/Wizard.stories.tsx +224 -0
  269. package/wizard/types.d.ts +60 -0
  270. package/wizard/types.js +5 -0
  271. package/README.md +0 -66
  272. package/babel.config.js +0 -8
  273. package/dist/BackgroundColorContext.js +0 -46
  274. package/dist/ThemeContext.js +0 -250
  275. package/dist/accordion/index.d.ts +0 -28
  276. package/dist/accordion-group/AccordionGroup.js +0 -186
  277. package/dist/accordion-group/index.d.ts +0 -16
  278. package/dist/alert/index.d.ts +0 -51
  279. package/dist/badge/Badge.js +0 -63
  280. package/dist/box/index.d.ts +0 -25
  281. package/dist/button/index.d.ts +0 -24
  282. package/dist/card/index.d.ts +0 -22
  283. package/dist/checkbox/index.d.ts +0 -24
  284. package/dist/chip/index.d.ts +0 -22
  285. package/dist/date-input/index.d.ts +0 -95
  286. package/dist/dialog/index.d.ts +0 -18
  287. package/dist/dropdown/index.d.ts +0 -26
  288. package/dist/file-input/FileInput.js +0 -644
  289. package/dist/file-input/FileItem.js +0 -287
  290. package/dist/file-input/index.d.ts +0 -81
  291. package/dist/footer/Footer.js +0 -421
  292. package/dist/footer/index.d.ts +0 -25
  293. package/dist/header/index.d.ts +0 -25
  294. package/dist/heading/index.d.ts +0 -17
  295. package/dist/link/index.d.ts +0 -23
  296. package/dist/main.d.ts +0 -40
  297. package/dist/number-input/NumberInput.js +0 -136
  298. package/dist/number-input/index.d.ts +0 -113
  299. package/dist/paginator/Paginator.js +0 -283
  300. package/dist/paginator/index.d.ts +0 -20
  301. package/dist/password-input/index.d.ts +0 -94
  302. package/dist/progress-bar/index.d.ts +0 -18
  303. package/dist/radio/index.d.ts +0 -23
  304. package/dist/resultsetTable/index.d.ts +0 -19
  305. package/dist/select/index.d.ts +0 -53
  306. package/dist/sidenav/index.d.ts +0 -13
  307. package/dist/slider/index.d.ts +0 -29
  308. package/dist/spinner/Spinner.js +0 -381
  309. package/dist/spinner/index.d.ts +0 -17
  310. package/dist/switch/index.d.ts +0 -24
  311. package/dist/table/index.d.ts +0 -13
  312. package/dist/tabs/Tabs.js +0 -343
  313. package/dist/tabs/index.d.ts +0 -19
  314. package/dist/tag/Tag.js +0 -282
  315. package/dist/tag/index.d.ts +0 -24
  316. package/dist/text-input/index.d.ts +0 -135
  317. package/dist/textarea/index.d.ts +0 -117
  318. package/dist/toggle-group/index.d.ts +0 -21
  319. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -135
  320. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  321. package/dist/upload/file-upload/FileToUpload.js +0 -189
  322. package/dist/upload/transaction/Transaction.js +0 -148
  323. package/dist/upload/transactions/Transactions.js +0 -138
  324. package/dist/wizard/Icons.js +0 -65
  325. package/dist/wizard/Wizard.js +0 -405
  326. package/dist/wizard/index.d.ts +0 -18
  327. package/test/Accordion.test.js +0 -33
  328. package/test/AccordionGroup.test.js +0 -125
  329. package/test/Alert.test.js +0 -53
  330. package/test/Box.test.js +0 -10
  331. package/test/Button.test.js +0 -18
  332. package/test/Card.test.js +0 -30
  333. package/test/Checkbox.test.js +0 -45
  334. package/test/Chip.test.js +0 -25
  335. package/test/Date.test.js +0 -395
  336. package/test/DateInput.test.js +0 -242
  337. package/test/Dialog.test.js +0 -23
  338. package/test/Dropdown.test.js +0 -145
  339. package/test/FileInput.test.js +0 -201
  340. package/test/Footer.test.js +0 -94
  341. package/test/Header.test.js +0 -34
  342. package/test/Heading.test.js +0 -83
  343. package/test/InputText.test.js +0 -248
  344. package/test/Link.test.js +0 -43
  345. package/test/NumberInput.test.js +0 -259
  346. package/test/Paginator.test.js +0 -177
  347. package/test/PasswordInput.test.js +0 -83
  348. package/test/ProgressBar.test.js +0 -35
  349. package/test/Radio.test.js +0 -37
  350. package/test/ResultsetTable.test.js +0 -329
  351. package/test/Sidenav.test.js +0 -45
  352. package/test/Slider.test.js +0 -74
  353. package/test/Spinner.test.js +0 -32
  354. package/test/Switch.test.js +0 -45
  355. package/test/Table.test.js +0 -36
  356. package/test/Tabs.test.js +0 -109
  357. package/test/Tag.test.js +0 -32
  358. package/test/TextInput.test.js +0 -732
  359. package/test/Textarea.test.js +0 -193
  360. package/test/ToggleGroup.test.js +0 -85
  361. package/test/Upload.test.js +0 -60
  362. package/test/V3Select.test.js +0 -212
  363. package/test/V3TextArea.test.js +0 -51
  364. package/test/Wizard.test.js +0 -130
  365. package/test/mocks/pngMock.js +0 -1
  366. 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 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
- });
@@ -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
- });
@@ -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
- });
@@ -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
- });
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
- });