@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,94 +0,0 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react";
3
- import DxcFooter from "../src/footer/Footer";
4
- import icon from "../../app/src/images/linkedin.svg";
5
-
6
- describe("Footer component tests", () => {
7
- test("Footer renders with default logo", () => {
8
- const { getByTitle } = render(<DxcFooter></DxcFooter>);
9
- expect(getByTitle("DXC Logo")).toBeTruthy();
10
- });
11
-
12
- test("Footer renders with social links", () => {
13
- const social = [
14
- {
15
- href: "https://www.test.com/test",
16
- logoSrc: icon,
17
- },
18
- ];
19
- const { getByRole } = render(<DxcFooter socialLinks={social}></DxcFooter>);
20
- const socialIcon = getByRole("link");
21
- expect(socialIcon.getAttribute("href")).toBe("https://www.test.com/test");
22
- });
23
-
24
- test("Footer renders with bottom links", () => {
25
- const bottom = [
26
- {
27
- href: "https://www.test.com/test",
28
- text: "bottom-link-text",
29
- },
30
- ];
31
- const { getByText } = render(<DxcFooter bottomLinks={bottom}></DxcFooter>);
32
- const link = getByText("bottom-link-text");
33
- expect(link.getAttribute("href")).toBe("https://www.test.com/test");
34
- });
35
-
36
- test("Footer renders with copyright text", () => {
37
- const { getByText } = render(<DxcFooter copyright="test-copyright"></DxcFooter>);
38
- expect(getByText("test-copyright")).toBeTruthy();
39
- });
40
-
41
- test("Footer renders with correct children", () => {
42
- //We need to force the offsetWidth value
43
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 1024 });
44
-
45
- const { getByText } = render(
46
- <DxcFooter>
47
- <p>footer-child-text</p>
48
- </DxcFooter>
49
- );
50
-
51
- expect(getByText("footer-child-text")).toBeTruthy();
52
- });
53
-
54
- test("Footer renders without children in mobile", () => {
55
- //425 is mobile width
56
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 425 });
57
-
58
- const { queryByText } = render(
59
- <DxcFooter>
60
- <p>footer-child-text</p>
61
- </DxcFooter>
62
- );
63
-
64
- expect(queryByText("footer-child-text")).toBeFalsy();
65
- });
66
-
67
- test("Footer is fully rendered", () => {
68
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 1024 });
69
-
70
- const social = [
71
- {
72
- href: "https://www.test.com/social",
73
- logoSrc: icon,
74
- },
75
- ];
76
- const bottom = [
77
- {
78
- href: "https://www.test.com/bottom",
79
- text: "bottom-link-text",
80
- },
81
- ];
82
- const { getAllByRole, getByText } = render(
83
- <DxcFooter socialLinks={social} bottomLinks={bottom} copyright="test-copyright">
84
- <p>footer-child-text</p>
85
- </DxcFooter>
86
- );
87
- const socialIcon = getAllByRole("link")[0];
88
- expect(socialIcon.getAttribute("href")).toBe("https://www.test.com/social");
89
- const bottomLink = getByText("bottom-link-text");
90
- expect(bottomLink.getAttribute("href")).toBe("https://www.test.com/bottom");
91
- expect(getByText("test-copyright")).toBeTruthy();
92
- expect(getByText("footer-child-text")).toBeTruthy();
93
- });
94
- });
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent } from "@testing-library/react";
3
- import DxcHeader from "../src/header/Header";
4
- import icon from "../../app/src/images/linkedin.svg";
5
-
6
- describe("Header component tests", () => {
7
- test("Header renders with default logo", () => {
8
- const { getByTitle } = render(<DxcHeader></DxcHeader>);
9
- expect(getByTitle("DXC Logo")).toBeTruthy();
10
- });
11
-
12
- test("Call correct function on logo click", () => {
13
- const onClick = jest.fn();
14
- const { getByTitle } = render(<DxcHeader onClick={onClick}></DxcHeader>);
15
- const logo = getByTitle("DXC Logo");
16
- fireEvent.click(logo);
17
- expect(onClick).toHaveBeenCalled();
18
- });
19
-
20
- test("Header renders with correct children", () => {
21
- // We need to force the offsetWidth value
22
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 1024 });
23
-
24
- const { getByText } = render(<DxcHeader content={<p>header-child-text</p>}></DxcHeader>);
25
- expect(getByText("header-child-text")).toBeTruthy();
26
- });
27
-
28
- test("Header renders menu button in mobile", () => {
29
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", { configurable: true, value: 425 });
30
-
31
- const { getByText } = render(<DxcHeader responsiveContent={(closeMenu) => <p>header-child-text</p>}></DxcHeader>);
32
- expect(getByText("Menu")).toBeTruthy();
33
- });
34
- });
@@ -1,35 +0,0 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react";
3
- import DxcHeading from "../src/heading/Heading";
4
-
5
- describe("Heading component tests", () => {
6
- test("Footer renders with default level", () => {
7
- const { getByText } = render(<DxcHeading text="my-heading-test"></DxcHeading>);
8
- expect(getByText("my-heading-test")).toBeTruthy();
9
- });
10
-
11
- test("Footer renders with level 1", () => {
12
- const { getByText } = render(<DxcHeading text="my-heading-test" level={1}></DxcHeading>);
13
- expect(getByText("my-heading-test")).toBeTruthy();
14
- });
15
-
16
- test("Footer renders with level 2", () => {
17
- const { getByText } = render(<DxcHeading text="my-heading-test" level={2}></DxcHeading>);
18
- expect(getByText("my-heading-test")).toBeTruthy();
19
- });
20
-
21
- test("Footer renders with level 3", () => {
22
- const { getByText } = render(<DxcHeading text="my-heading-test" level={3}></DxcHeading>);
23
- expect(getByText("my-heading-test")).toBeTruthy();
24
- });
25
-
26
- test("Footer renders with level 4", () => {
27
- const { getByText } = render(<DxcHeading text="my-heading-test" level={4}></DxcHeading>);
28
- expect(getByText("my-heading-test")).toBeTruthy();
29
- });
30
-
31
- test("Footer renders with level 5", () => {
32
- const { getByText } = render(<DxcHeading text="my-heading-test" level={5}></DxcHeading>);
33
- expect(getByText("my-heading-test")).toBeTruthy();
34
- });
35
- });
@@ -1,248 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent, waitFor, screen, act, waitForElementToBeRemoved } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
-
5
- import icon from "../../app/src/images/invision.svg";
6
-
7
- import V3DxcInputText from "../src/input-text/InputText";
8
-
9
- const countries = ["Albania", "Andorra", "Armenia", "Austria", "Azerbaijan"];
10
-
11
- //Mock of popper.js because of an issue with createRange function
12
- //(https://github.com/popperjs/popper-core/issues/478)
13
- jest.mock("popper.js", () => {
14
- const PopperJS = jest.requireActual("popper.js");
15
-
16
- return class {
17
- static placements = PopperJS.placements;
18
-
19
- constructor() {
20
- return {
21
- destroy: () => {},
22
- scheduleUpdate: () => {},
23
- update: () => {},
24
- };
25
- }
26
- };
27
- });
28
-
29
- describe("InputText component tests", () => {
30
- test("Input renders with correct label", () => {
31
- const { getByText } = render(<V3DxcInputText label="Input label" />);
32
- expect(getByText("Input label")).toBeTruthy();
33
- });
34
-
35
- test("onChange function is called correctly", () => {
36
- const onChange = jest.fn();
37
- const { getByRole } = render(<V3DxcInputText label="Input label" onChange={onChange} />);
38
- const input = getByRole("textbox");
39
- userEvent.type(input, "20000");
40
- expect(onChange).toHaveBeenCalled();
41
- expect(onChange).toHaveBeenCalledWith("20000");
42
- });
43
- test("onBlur function is called correctly", () => {
44
- const onBlur = jest.fn();
45
- const onChange = jest.fn();
46
-
47
- const { getByRole } = render(<V3DxcInputText label="Input label" onChange={onChange} onBlur={onBlur} />);
48
- const input = getByRole("textbox");
49
- userEvent.type(input, "Test value");
50
- fireEvent.blur(input);
51
- expect(onBlur).toHaveBeenCalled();
52
- expect(onBlur).toHaveBeenCalledWith("Test value");
53
- });
54
-
55
- test("Uncontrolled component", () => {
56
- const onChange = jest.fn();
57
- const { getByRole } = render(<V3DxcInputText label="Input label" onChange={onChange} />);
58
- const input = getByRole("textbox");
59
- userEvent.type(input, "20000");
60
- expect(onChange).toHaveBeenCalled();
61
- expect(onChange).toHaveBeenCalledWith("20000");
62
- expect(input.value).toBe("20000");
63
- });
64
-
65
- test("Controlled component", () => {
66
- const onChange = jest.fn();
67
- const onBlur = jest.fn();
68
- const { getByRole } = render(
69
- <V3DxcInputText label="Input label" value="Test value" onChange={onChange} onBlur={onBlur} />
70
- );
71
- const input = getByRole("textbox");
72
- userEvent.type(input, "20000");
73
- expect(onChange).toHaveBeenCalled();
74
- expect(input.value).toBe("Test value");
75
- fireEvent.blur(input);
76
- expect(onBlur).toHaveBeenCalled();
77
- expect(onBlur).toHaveBeenCalledWith("Test value");
78
- });
79
- test("Prefix icon onClick", () => {
80
- const onClick = jest.fn();
81
- const { getByRole } = render(<V3DxcInputText label="Input label" prefixIconSrc={icon} onClickPrefix={onClick} />);
82
- const prefixIcon = getByRole("img");
83
- userEvent.click(prefixIcon);
84
- expect(onClick).toHaveBeenCalled();
85
- });
86
- test("Suffix icon onClick", () => {
87
- const onClick = jest.fn();
88
- const { getByRole } = render(<V3DxcInputText label="Input label" suffixIconSrc={icon} onClickSuffix={onClick} />);
89
- const suffixIcon = getByRole("img");
90
- userEvent.click(suffixIcon);
91
- expect(onClick).toHaveBeenCalled();
92
- });
93
- });
94
-
95
- describe("Autocomplete component Synchronous tests", () => {
96
- test("Autocomplete no matches found is shown", async () => {
97
- const onChangeAtocomplete = jest.fn();
98
- render(
99
- <V3DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
100
- );
101
- const input = screen.getByRole("textbox");
102
- fireEvent.focus(input);
103
- expect(screen.getByText("Andorra")).toBeTruthy();
104
- userEvent.type(input, "X");
105
- expect(screen.getByText("No matches found.")).toBeTruthy();
106
- });
107
-
108
- test("Autocomplete suggestions are shown", async () => {
109
- const onChangeAtocomplete = jest.fn();
110
- render(
111
- <V3DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
112
- );
113
- const input = screen.getByRole("textbox");
114
- fireEvent.focus(input);
115
- expect(screen.getByText("Andorra")).toBeTruthy();
116
- });
117
-
118
- test("Autocomplete UNCONTROLLED suggestion selected", async () => {
119
- const onChangeAtocomplete = jest.fn();
120
- render(
121
- <V3DxcInputText label="Autocomplete Countries" autocompleteOptions={countries} onChange={onChangeAtocomplete} />
122
- );
123
- const input = screen.getByRole("textbox");
124
- fireEvent.focus(input);
125
- expect(screen.getByText("Andorra")).toBeTruthy();
126
- userEvent.type(screen.getByRole("textbox"), "Alb");
127
- expect(onChangeAtocomplete).toHaveBeenCalled();
128
- expect(screen.getByText("Albania")).toBeTruthy();
129
- const suggestion1 = screen.getByText("Albania");
130
- act(() => {
131
- userEvent.click(suggestion1);
132
- });
133
-
134
- // expect(onChangeAtocomplete).toHaveBeenCalledWith("Albania");
135
- expect(screen.getByRole("textbox").value).toBe("Albania");
136
- });
137
-
138
- test("Autocomplete CONTROLLED suggestions selected", async () => {
139
- const onChangeAtocomplete = jest.fn();
140
- render(
141
- <V3DxcInputText
142
- label="Autocomplete Countries"
143
- value="Andorra"
144
- autocompleteOptions={countries}
145
- onChange={onChangeAtocomplete}
146
- />
147
- );
148
- const input = screen.getByRole("textbox");
149
- fireEvent.focus(input);
150
- expect(screen.getByText("Andorra")).toBeTruthy();
151
-
152
- expect(screen.getByText("Andorra")).toBeTruthy();
153
- const suggestion1 = screen.getByText("Andorra");
154
- act(() => {
155
- userEvent.click(suggestion1);
156
- });
157
-
158
- expect(onChangeAtocomplete).toHaveBeenCalledWith("Andorra");
159
- });
160
- });
161
-
162
- describe("InputText component Asynchronous Autocomplete tests", () => {
163
- test("Autocomplete Searching is shown", async () => {
164
- const callbackFunc = jest.fn(() => new Promise((resolve) => setTimeout(resolve(["Italy", "Spain"]), 1000)));
165
-
166
- const onChangeAtocomplete = jest.fn();
167
- render(
168
- <V3DxcInputText
169
- label="Autocomplete Countries"
170
- autocompleteOptions={callbackFunc}
171
- onChange={onChangeAtocomplete}
172
- />
173
- );
174
- const input = screen.getByRole("textbox");
175
- fireEvent.focus(input);
176
- await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
177
- expect(screen.getByText("Italy")).toBeTruthy();
178
- expect(screen.getByText("Spain")).toBeTruthy();
179
- });
180
-
181
- test("Asynchronous UNCONTROLLED autocomplete tests", async () => {
182
- const callbackFunc = jest.fn(() => new Promise((resolve) => setTimeout(resolve(["Italy", "Spain"]), 1000)));
183
- const onChangeAtocomplete = jest.fn();
184
- render(
185
- <V3DxcInputText
186
- label="Autocomplete Countries"
187
- onChange={onChangeAtocomplete}
188
- autocompleteOptions={callbackFunc}
189
- />
190
- );
191
- const input = screen.getByRole("textbox");
192
- fireEvent.focus(input);
193
- userEvent.type(input, "And");
194
- await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
195
- expect(screen.getByText("Italy")).toBeTruthy();
196
- expect(screen.getByText("Spain")).toBeTruthy();
197
- const suggestion1 = screen.getByText("Spain");
198
- act(() => {
199
- userEvent.click(suggestion1);
200
- });
201
- expect(onChangeAtocomplete).toHaveBeenCalledWith("Spain");
202
- expect(screen.getByRole("textbox").value).toBe("Spain");
203
- });
204
-
205
- test("Asynchronous CONTROLLED autocomplete tests", async () => {
206
- const callbackFunc = jest.fn(() => new Promise((resolve) => setTimeout(resolve(["Italy", "Spain"]), 3000)));
207
- const onChangeAtocomplete = jest.fn();
208
- render(
209
- <V3DxcInputText
210
- label="Autocomplete Countries"
211
- value="test value"
212
- onChange={onChangeAtocomplete}
213
- autocompleteOptions={callbackFunc}
214
- />
215
- );
216
- const input = screen.getByRole("textbox");
217
- fireEvent.focus(input);
218
- userEvent.type(input, "And");
219
- await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
220
- expect(screen.getByText("Italy")).toBeTruthy();
221
- expect(screen.getByText("Spain")).toBeTruthy();
222
- const suggestion1 = screen.getByText("Spain");
223
- act(() => {
224
- userEvent.click(suggestion1);
225
- });
226
- expect(onChangeAtocomplete).toHaveBeenCalledWith("Spain");
227
- expect(screen.getByRole("textbox").value).toBe("test value");
228
- });
229
-
230
- test("Asynchronous autocomplete request failed", async () => {
231
- const errorCallbackFunc = jest.fn(() => new Promise((resolve, reject) => setTimeout(reject("E"), 3000)));
232
- const onChangeAtocomplete = jest.fn();
233
-
234
- render(
235
- <V3DxcInputText
236
- label="Autocomplete Countries"
237
- value="test value"
238
- onChange={onChangeAtocomplete}
239
- autocompleteOptions={errorCallbackFunc}
240
- />
241
- );
242
-
243
- const input = screen.getByRole("textbox");
244
- fireEvent.focus(input);
245
- await waitForElementToBeRemoved(() => screen.getByText(/Searching.../i));
246
- expect(screen.getByText("Error fetching data")).toBeTruthy();
247
- });
248
- });
package/test/Link.test.js DELETED
@@ -1,43 +0,0 @@
1
- import React from "react";
2
- import { render, fireEvent } from "@testing-library/react";
3
- import DxcLink from "../src/link/Link";
4
-
5
- describe("Link component tests", () => {
6
- test("Link renders with correct text", () => {
7
- const { getByText } = render(<DxcLink text="Link" />);
8
- expect(getByText("Link")).toBeTruthy();
9
- });
10
-
11
- test("Link renders with correct href", () => {
12
- const { getByRole } = render(<DxcLink text="Link" href="/testPage" />);
13
- expect(getByRole("link").getAttribute("href")).toEqual("/testPage");
14
- });
15
-
16
- test("Link renders with correct disabled state", () => {
17
- const { getByText } = render(<DxcLink text="Link" href="/testPage" disabled={true} />);
18
- expect(getByText("Link").hasAttribute("href")).toBeFalsy();
19
- const { getByText: getByTextLinkButton } = render(<DxcLink text="LinkButton" onClick={() => console.log("Andorra")} disabled={true} />);
20
- expect(getByTextLinkButton("LinkButton").hasAttribute("onclick")).toBeFalsy();
21
- });
22
-
23
- test("Link open new tab", () => {
24
- const { getByRole } = render(<DxcLink text="Link" href="/testPage" newWindow={true} />);
25
- expect(getByRole("link").getAttribute("target")).toEqual("_blank");
26
- });
27
-
28
- test("Link onClick called", () => {
29
- const onClick = jest.fn();
30
- const { getByText } = render(<DxcLink text="Link" onClick={onClick} />);
31
- const link = getByText("Link");
32
- fireEvent.click(link);
33
- expect(onClick).toHaveBeenCalled();
34
- });
35
-
36
- test("Disabled link onClick not called", () => {
37
- const onClick = jest.fn();
38
- const { getByText } = render(<DxcLink text="Link" onClick={onClick} disabled={true} />);
39
- const link = getByText("Link");
40
- fireEvent.click(link);
41
- expect(onClick).toHaveBeenCalledTimes(0);
42
- });
43
- });