@dxc-technology/halstack-react 0.0.0-4727df3 → 0.0.0-4970b2f

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 (252) 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/types.d.ts +49 -0
  18. package/alert/types.js +5 -0
  19. package/badge/Badge.js +59 -0
  20. package/{dist/box → box}/Box.js +9 -13
  21. package/box/index.d.ts +25 -0
  22. package/button/Button.d.ts +4 -0
  23. package/{dist/button → button}/Button.js +16 -72
  24. package/button/Button.stories.tsx +293 -0
  25. package/button/types.d.ts +57 -0
  26. package/button/types.js +5 -0
  27. package/{dist/card → card}/Card.js +19 -73
  28. package/card/index.d.ts +22 -0
  29. package/checkbox/Checkbox.d.ts +4 -0
  30. package/{dist/checkbox → checkbox}/Checkbox.js +16 -63
  31. package/checkbox/types.d.ts +60 -0
  32. package/checkbox/types.js +5 -0
  33. package/{dist/chip → chip}/Chip.js +17 -61
  34. package/chip/index.d.ts +22 -0
  35. package/{dist/common → common}/OpenSans.css +0 -0
  36. package/{dist/common → common}/RequiredComponent.js +3 -11
  37. package/{dist/common → common}/fonts/OpenSans-Bold.ttf +0 -0
  38. package/{dist/common → common}/fonts/OpenSans-BoldItalic.ttf +0 -0
  39. package/{dist/common → common}/fonts/OpenSans-ExtraBold.ttf +0 -0
  40. package/{dist/common → common}/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  41. package/{dist/common → common}/fonts/OpenSans-Italic.ttf +0 -0
  42. package/{dist/common → common}/fonts/OpenSans-Light.ttf +0 -0
  43. package/{dist/common → common}/fonts/OpenSans-LightItalic.ttf +0 -0
  44. package/{dist/common → common}/fonts/OpenSans-Regular.ttf +0 -0
  45. package/{dist/common → common}/fonts/OpenSans-SemiBold.ttf +0 -0
  46. package/{dist/common → common}/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  47. package/{dist/common → common}/utils.js +0 -0
  48. package/{dist/common → common}/variables.js +131 -131
  49. package/{dist/date → date}/Date.js +21 -27
  50. package/date/index.d.ts +27 -0
  51. package/date-input/DateInput.d.ts +4 -0
  52. package/{dist/date-input → date-input}/DateInput.js +22 -61
  53. package/date-input/types.d.ts +100 -0
  54. package/date-input/types.js +5 -0
  55. package/{dist/dialog → dialog}/Dialog.js +16 -50
  56. package/dialog/index.d.ts +18 -0
  57. package/{dist/dropdown → dropdown}/Dropdown.js +37 -131
  58. package/dropdown/index.d.ts +26 -0
  59. package/{dist/file-input → file-input}/FileInput.js +49 -161
  60. package/{dist/file-input → file-input}/FileItem.js +36 -123
  61. package/{dist/file-input → file-input}/index.d.ts +1 -1
  62. package/{dist/footer → footer}/Footer.js +34 -158
  63. package/{dist/footer → footer}/Icons.js +13 -13
  64. package/footer/index.d.ts +25 -0
  65. package/{dist/header → header}/Header.js +62 -170
  66. package/{dist/header → header}/Icons.js +11 -11
  67. package/header/index.d.ts +25 -0
  68. package/{dist/heading → heading}/Heading.js +30 -72
  69. package/heading/index.d.ts +17 -0
  70. package/{dist/input-text → input-text}/Icons.js +2 -2
  71. package/{dist/input-text → input-text}/InputText.js +36 -130
  72. package/input-text/index.d.ts +36 -0
  73. package/{dist/layout → layout}/ApplicationLayout.js +35 -131
  74. package/layout/Icons.js +55 -0
  75. package/{dist/link → link}/Link.js +18 -72
  76. package/link/index.d.ts +23 -0
  77. package/main.d.ts +44 -0
  78. package/{dist/main.js → main.js} +93 -97
  79. package/{dist/number-input → number-input}/NumberInput.js +5 -13
  80. package/{dist/number-input → number-input}/NumberInputContext.js +1 -1
  81. package/{dist/number-input → number-input}/index.d.ts +0 -0
  82. package/package.json +32 -25
  83. package/paginator/Icons.js +66 -0
  84. package/paginator/Paginator.d.ts +4 -0
  85. package/paginator/Paginator.js +198 -0
  86. package/paginator/types.d.ts +38 -0
  87. package/paginator/types.js +5 -0
  88. package/{dist/password-input → password-input}/PasswordInput.js +23 -22
  89. package/password-input/PasswordInput.stories.jsx +131 -0
  90. package/{dist/password-input → password-input}/index.d.ts +0 -0
  91. package/{dist/progress-bar → progress-bar}/ProgressBar.js +18 -72
  92. package/progress-bar/index.d.ts +18 -0
  93. package/radio/Radio.d.ts +4 -0
  94. package/{dist/radio → radio}/Radio.js +15 -50
  95. package/radio/types.d.ts +54 -0
  96. package/radio/types.js +5 -0
  97. package/{dist/resultsetTable → resultsetTable}/ResultsetTable.js +35 -119
  98. package/resultsetTable/index.d.ts +19 -0
  99. package/select/Select.js +865 -0
  100. package/select/index.d.ts +131 -0
  101. package/{dist/sidenav → sidenav}/Sidenav.js +15 -49
  102. package/sidenav/index.d.ts +13 -0
  103. package/{dist/slider → slider}/Slider.js +33 -87
  104. package/slider/index.d.ts +29 -0
  105. package/{dist/spinner → spinner}/Spinner.js +38 -152
  106. package/spinner/index.d.ts +17 -0
  107. package/switch/Switch.d.ts +4 -0
  108. package/{dist/switch → switch}/Switch.js +26 -69
  109. package/switch/types.d.ts +58 -0
  110. package/switch/types.js +5 -0
  111. package/{dist/table → table}/Table.js +10 -24
  112. package/table/index.d.ts +13 -0
  113. package/{dist/tabs → tabs}/Tabs.js +26 -110
  114. package/tabs/index.d.ts +19 -0
  115. package/{dist/tag → tag}/Tag.js +22 -96
  116. package/tag/index.d.ts +24 -0
  117. package/{dist/text-input → text-input}/TextInput.js +244 -390
  118. package/{dist/text-input → text-input}/index.d.ts +0 -0
  119. package/{dist/textarea → textarea}/Textarea.js +20 -72
  120. package/{dist/textarea → textarea}/index.d.ts +0 -0
  121. package/{dist/toggle → toggle}/Toggle.js +15 -49
  122. package/toggle/index.d.ts +21 -0
  123. package/{dist/toggle-group → toggle-group}/ToggleGroup.js +23 -107
  124. package/toggle-group/index.d.ts +21 -0
  125. package/{dist/upload → upload}/Upload.js +14 -18
  126. package/upload/buttons-upload/ButtonsUpload.js +111 -0
  127. package/upload/buttons-upload/Icons.js +40 -0
  128. package/upload/dragAndDropArea/DragAndDropArea.js +225 -0
  129. package/upload/dragAndDropArea/Icons.js +39 -0
  130. package/upload/file-upload/FileToUpload.js +115 -0
  131. package/upload/file-upload/Icons.js +66 -0
  132. package/{dist/upload → upload}/files-upload/FilesToUpload.js +12 -26
  133. package/upload/index.d.ts +15 -0
  134. package/upload/transaction/Icons.js +160 -0
  135. package/upload/transaction/Transaction.js +104 -0
  136. package/upload/transactions/Transactions.js +94 -0
  137. package/{dist/useTheme.js → useTheme.js} +0 -0
  138. package/wizard/Icons.js +65 -0
  139. package/{dist/wizard → wizard}/Wizard.js +32 -172
  140. package/wizard/index.d.ts +18 -0
  141. package/README.md +0 -66
  142. package/babel.config.js +0 -8
  143. package/dist/BackgroundColorContext.js +0 -46
  144. package/dist/ThemeContext.js +0 -248
  145. package/dist/accordion-group/AccordionGroup.js +0 -186
  146. package/dist/alert/index.d.ts +0 -51
  147. package/dist/badge/Badge.js +0 -63
  148. package/dist/checkbox/Checkbox.stories.js +0 -144
  149. package/dist/checkbox/readme.md +0 -116
  150. package/dist/date/Date.stories.js +0 -205
  151. package/dist/date/readme.md +0 -73
  152. package/dist/date-input/index.d.ts +0 -95
  153. package/dist/layout/facebook.svg +0 -45
  154. package/dist/layout/linkedin.svg +0 -50
  155. package/dist/layout/twitter.svg +0 -53
  156. package/dist/link/readme.md +0 -51
  157. package/dist/main.d.ts +0 -8
  158. package/dist/new-select/NewSelect.js +0 -836
  159. package/dist/new-select/index.d.ts +0 -53
  160. package/dist/paginator/Paginator.js +0 -289
  161. package/dist/paginator/images/next.svg +0 -3
  162. package/dist/paginator/images/nextPage.svg +0 -3
  163. package/dist/paginator/images/previous.svg +0 -3
  164. package/dist/paginator/images/previousPage.svg +0 -3
  165. package/dist/paginator/readme.md +0 -50
  166. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  167. package/dist/progress-bar/readme.md +0 -63
  168. package/dist/radio/Radio.stories.js +0 -166
  169. package/dist/radio/readme.md +0 -70
  170. package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
  171. package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
  172. package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
  173. package/dist/slider/readme.md +0 -64
  174. package/dist/spinner/Spinner.stories.js +0 -183
  175. package/dist/spinner/readme.md +0 -65
  176. package/dist/switch/Switch.stories.js +0 -134
  177. package/dist/switch/readme.md +0 -133
  178. package/dist/tabs/Tabs.stories.js +0 -130
  179. package/dist/tabs/readme.md +0 -78
  180. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  181. package/dist/tabs-for-sections/readme.md +0 -78
  182. package/dist/toggle/Toggle.stories.js +0 -297
  183. package/dist/toggle/readme.md +0 -80
  184. package/dist/upload/Upload.stories.js +0 -72
  185. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
  186. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  187. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  188. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  189. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  190. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  191. package/dist/upload/file-upload/FileToUpload.js +0 -184
  192. package/dist/upload/file-upload/audio-icon.svg +0 -4
  193. package/dist/upload/file-upload/close.svg +0 -4
  194. package/dist/upload/file-upload/file-icon.svg +0 -4
  195. package/dist/upload/file-upload/video-icon.svg +0 -4
  196. package/dist/upload/readme.md +0 -37
  197. package/dist/upload/transaction/Transaction.js +0 -175
  198. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  199. package/dist/upload/transaction/audio-icon.svg +0 -4
  200. package/dist/upload/transaction/error-icon.svg +0 -4
  201. package/dist/upload/transaction/file-icon-err.svg +0 -4
  202. package/dist/upload/transaction/file-icon.svg +0 -4
  203. package/dist/upload/transaction/image-icon-err.svg +0 -4
  204. package/dist/upload/transaction/image-icon.svg +0 -4
  205. package/dist/upload/transaction/success-icon.svg +0 -4
  206. package/dist/upload/transaction/video-icon-err.svg +0 -4
  207. package/dist/upload/transaction/video-icon.svg +0 -4
  208. package/dist/upload/transactions/Transactions.js +0 -138
  209. package/dist/wizard/invalid_icon.svg +0 -5
  210. package/dist/wizard/valid_icon.svg +0 -5
  211. package/dist/wizard/validation-wrong.svg +0 -6
  212. package/test/Accordion.test.js +0 -33
  213. package/test/AccordionGroup.test.js +0 -125
  214. package/test/Alert.test.js +0 -53
  215. package/test/Box.test.js +0 -10
  216. package/test/Button.test.js +0 -18
  217. package/test/Card.test.js +0 -30
  218. package/test/Checkbox.test.js +0 -45
  219. package/test/Chip.test.js +0 -25
  220. package/test/Date.test.js +0 -397
  221. package/test/DateInput.test.js +0 -242
  222. package/test/Dialog.test.js +0 -23
  223. package/test/Dropdown.test.js +0 -145
  224. package/test/FileInput.test.js +0 -201
  225. package/test/Footer.test.js +0 -94
  226. package/test/Header.test.js +0 -34
  227. package/test/Heading.test.js +0 -35
  228. package/test/InputText.test.js +0 -248
  229. package/test/Link.test.js +0 -43
  230. package/test/NumberInput.test.js +0 -259
  231. package/test/Paginator.test.js +0 -177
  232. package/test/PasswordInput.test.js +0 -83
  233. package/test/ProgressBar.test.js +0 -35
  234. package/test/Radio.test.js +0 -37
  235. package/test/ResultsetTable.test.js +0 -329
  236. package/test/Select.test.js +0 -212
  237. package/test/Sidenav.test.js +0 -45
  238. package/test/Slider.test.js +0 -82
  239. package/test/Spinner.test.js +0 -32
  240. package/test/Switch.test.js +0 -45
  241. package/test/Table.test.js +0 -36
  242. package/test/Tabs.test.js +0 -109
  243. package/test/TabsForSections.test.js +0 -34
  244. package/test/Tag.test.js +0 -32
  245. package/test/TextInput.test.js +0 -732
  246. package/test/Textarea.test.js +0 -193
  247. package/test/ToggleGroup.test.js +0 -85
  248. package/test/Upload.test.js +0 -60
  249. package/test/V3TextArea.test.js +0 -51
  250. package/test/Wizard.test.js +0 -130
  251. package/test/mocks/pngMock.js +0 -1
  252. 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
- });