@onewelcome/react-lib-components 5.2.0 → 6.1.0

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 (255) hide show
  1. package/dist/cjs/Button/BaseButton.cjs.js.map +1 -1
  2. package/dist/cjs/Button/BaseButton.module.cjs.js +1 -1
  3. package/dist/cjs/Button/Button.module.cjs.js +1 -1
  4. package/dist/cjs/Button/IconButton.module.cjs.js +1 -1
  5. package/dist/cjs/ContextMenu/ContextMenu.cjs.js +1 -1
  6. package/dist/cjs/ContextMenu/ContextMenu.cjs.js.map +1 -1
  7. package/dist/cjs/ContextMenu/ContextMenuItem.module.cjs.js +1 -1
  8. package/dist/cjs/ContextMenu/ContextMenuService.cjs.js +1 -1
  9. package/dist/cjs/ContextMenu/ContextMenuService.cjs.js.map +1 -1
  10. package/dist/cjs/DataGrid/DataGridActions/DataGridColumnsToggle.module.cjs.js +1 -1
  11. package/dist/cjs/Form/Input/Input.module.cjs.js +1 -1
  12. package/dist/cjs/Form/Select/Option.cjs.js +1 -1
  13. package/dist/cjs/Form/Select/Option.cjs.js.map +1 -1
  14. package/dist/cjs/Form/Select/Select.cjs.js +1 -1
  15. package/dist/cjs/Form/Select/Select.cjs.js.map +1 -1
  16. package/dist/cjs/Form/Select/Select.module.cjs.js +1 -1
  17. package/dist/cjs/Form/Select/SelectService.cjs.js +1 -1
  18. package/dist/cjs/Form/Select/SelectService.cjs.js.map +1 -1
  19. package/dist/cjs/Form/Textarea/Textarea.module.cjs.js +1 -1
  20. package/dist/cjs/Icon/Icon.cjs.js +1 -1
  21. package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
  22. package/dist/cjs/Icon/Icon.module.cjs.js +1 -1
  23. package/dist/cjs/Link/Link.cjs.js.map +1 -1
  24. package/dist/cjs/Link/Link.module.cjs.js +1 -1
  25. package/dist/cjs/Notifications/BaseModal/BaseModal.module.cjs.js +1 -1
  26. package/dist/cjs/Notifications/SlideInModal/SlideInModal.module.cjs.js +1 -1
  27. package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js +1 -1
  28. package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js.map +1 -1
  29. package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.cjs.js +1 -1
  30. package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js +1 -1
  31. package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js.map +1 -1
  32. package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.cjs.js.map +1 -1
  33. package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js +2 -0
  34. package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js.map +1 -0
  35. package/dist/cjs/Popover/Popover.cjs.js +1 -1
  36. package/dist/cjs/Popover/Popover.cjs.js.map +1 -1
  37. package/dist/cjs/Popover/Popover.module.cjs.js +1 -1
  38. package/dist/cjs/Stepper/Step.cjs.js +1 -1
  39. package/dist/cjs/Stepper/Step.cjs.js.map +1 -1
  40. package/dist/cjs/Stepper/Step.module.cjs.js +1 -1
  41. package/dist/cjs/Stepper/Stepper.cjs.js +1 -1
  42. package/dist/cjs/Stepper/Stepper.cjs.js.map +1 -1
  43. package/dist/cjs/Tabs/TabButton.module.cjs.js +1 -1
  44. package/dist/cjs/TextEllipsis/TextEllipsis.module.cjs.js +1 -1
  45. package/dist/cjs/Tiles/Tile.module.cjs.js +1 -1
  46. package/dist/cjs/Tooltip/Tooltip.module.cjs.js +1 -1
  47. package/dist/cjs/Wizard/BaseWizardSteps/BaseWizardSteps.module.cjs.js +1 -1
  48. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js +1 -1
  49. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
  50. package/dist/cjs/src/.scope.d.ts +2 -0
  51. package/dist/cjs/src/components/Button/BaseButton.d.ts +1 -1
  52. package/dist/cjs/src/components/ContextMenu/ContextMenu.d.ts +1 -1
  53. package/dist/cjs/src/components/ContextMenu/ContextMenuService.d.ts +4 -1
  54. package/dist/cjs/src/components/Form/Select/Option.d.ts +1 -0
  55. package/dist/cjs/src/components/Form/Select/Select.d.ts +20 -0
  56. package/dist/cjs/src/components/Form/Select/Select.interfaces.d.ts +3 -1
  57. package/dist/cjs/src/components/Form/Select/Select.test.d.ts +63 -1
  58. package/dist/cjs/src/components/Form/Select/SelectKeyboardNavigation.test.d.ts +1 -0
  59. package/dist/cjs/src/components/Form/Select/SelectService.d.ts +3 -2
  60. package/dist/cjs/src/components/Icon/Icon.d.ts +4 -1
  61. package/dist/cjs/src/components/Link/Link.d.ts +1 -1
  62. package/dist/cjs/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
  63. package/dist/cjs/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
  64. package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
  65. package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
  66. package/dist/cjs/src/components/Stepper/Stepper.d.ts +0 -1
  67. package/dist/cjs/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
  68. package/dist/cjs/src/hooks/usePosition.cjs.js.map +1 -1
  69. package/dist/cjs/src/hooks/usePosition.d.ts +1 -1
  70. package/dist/esm/Button/BaseButton.esm.js.map +1 -1
  71. package/dist/esm/Button/BaseButton.module.esm.js +1 -1
  72. package/dist/esm/Button/Button.module.esm.js +1 -1
  73. package/dist/esm/Button/IconButton.module.esm.js +1 -1
  74. package/dist/esm/ContextMenu/ContextMenu.esm.js +1 -1
  75. package/dist/esm/ContextMenu/ContextMenu.esm.js.map +1 -1
  76. package/dist/esm/ContextMenu/ContextMenuItem.module.esm.js +1 -1
  77. package/dist/esm/ContextMenu/ContextMenuService.esm.js +1 -1
  78. package/dist/esm/ContextMenu/ContextMenuService.esm.js.map +1 -1
  79. package/dist/esm/DataGrid/DataGridActions/DataGridColumnsToggle.module.esm.js +1 -1
  80. package/dist/esm/Form/Input/Input.module.esm.js +1 -1
  81. package/dist/esm/Form/Select/Option.esm.js +1 -1
  82. package/dist/esm/Form/Select/Option.esm.js.map +1 -1
  83. package/dist/esm/Form/Select/Select.esm.js +1 -1
  84. package/dist/esm/Form/Select/Select.esm.js.map +1 -1
  85. package/dist/esm/Form/Select/Select.module.esm.js +1 -1
  86. package/dist/esm/Form/Select/SelectService.esm.js +1 -1
  87. package/dist/esm/Form/Select/SelectService.esm.js.map +1 -1
  88. package/dist/esm/Form/Textarea/Textarea.module.esm.js +1 -1
  89. package/dist/esm/Icon/Icon.esm.js +1 -1
  90. package/dist/esm/Icon/Icon.esm.js.map +1 -1
  91. package/dist/esm/Icon/Icon.module.esm.js +1 -1
  92. package/dist/esm/Link/Link.esm.js.map +1 -1
  93. package/dist/esm/Link/Link.module.esm.js +1 -1
  94. package/dist/esm/Notifications/BaseModal/BaseModal.module.esm.js +1 -1
  95. package/dist/esm/Notifications/SlideInModal/SlideInModal.module.esm.js +1 -1
  96. package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js +1 -1
  97. package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js.map +1 -1
  98. package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.esm.js +1 -1
  99. package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js +1 -1
  100. package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js.map +1 -1
  101. package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.esm.js.map +1 -1
  102. package/dist/esm/Notifications/Snackbar/interfaces.esm.js +2 -0
  103. package/dist/esm/Notifications/Snackbar/interfaces.esm.js.map +1 -0
  104. package/dist/esm/Popover/Popover.esm.js +1 -1
  105. package/dist/esm/Popover/Popover.esm.js.map +1 -1
  106. package/dist/esm/Popover/Popover.module.esm.js +1 -1
  107. package/dist/esm/Stepper/Step.esm.js +1 -1
  108. package/dist/esm/Stepper/Step.esm.js.map +1 -1
  109. package/dist/esm/Stepper/Step.module.esm.js +1 -1
  110. package/dist/esm/Stepper/Stepper.esm.js +1 -1
  111. package/dist/esm/Stepper/Stepper.esm.js.map +1 -1
  112. package/dist/esm/Tabs/TabButton.module.esm.js +1 -1
  113. package/dist/esm/TextEllipsis/TextEllipsis.module.esm.js +1 -1
  114. package/dist/esm/Tiles/Tile.module.esm.js +1 -1
  115. package/dist/esm/Tooltip/Tooltip.module.esm.js +1 -1
  116. package/dist/esm/Wizard/BaseWizardSteps/BaseWizardSteps.module.esm.js +1 -1
  117. package/dist/esm/_BaseStyling_/BaseStyling.esm.js +1 -1
  118. package/dist/esm/_BaseStyling_/BaseStyling.esm.js.map +1 -1
  119. package/dist/esm/src/.scope.d.ts +2 -0
  120. package/dist/esm/src/components/Button/BaseButton.d.ts +1 -1
  121. package/dist/esm/src/components/ContextMenu/ContextMenu.d.ts +1 -1
  122. package/dist/esm/src/components/ContextMenu/ContextMenuService.d.ts +4 -1
  123. package/dist/esm/src/components/Form/Select/Option.d.ts +1 -0
  124. package/dist/esm/src/components/Form/Select/Select.d.ts +20 -0
  125. package/dist/esm/src/components/Form/Select/Select.interfaces.d.ts +3 -1
  126. package/dist/esm/src/components/Form/Select/Select.test.d.ts +63 -1
  127. package/dist/esm/src/components/Form/Select/SelectKeyboardNavigation.test.d.ts +1 -0
  128. package/dist/esm/src/components/Form/Select/SelectService.d.ts +3 -2
  129. package/dist/esm/src/components/Icon/Icon.d.ts +4 -1
  130. package/dist/esm/src/components/Link/Link.d.ts +1 -1
  131. package/dist/esm/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
  132. package/dist/esm/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
  133. package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
  134. package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
  135. package/dist/esm/src/components/Stepper/Stepper.d.ts +0 -1
  136. package/dist/esm/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
  137. package/dist/esm/src/hooks/usePosition.d.ts +1 -1
  138. package/dist/esm/src/hooks/usePosition.esm.js.map +1 -1
  139. package/package.json +48 -45
  140. package/src/{hooks/useWrapper.test.ts → .scope.ts} +1 -12
  141. package/src/components/Button/BaseButton.tsx +1 -1
  142. package/src/components/Button/Button.module.scss +2 -10
  143. package/src/components/ContextMenu/ContextMenu.tsx +13 -23
  144. package/src/components/ContextMenu/ContextMenuService.ts +47 -1
  145. package/src/components/Form/Select/Option.tsx +3 -1
  146. package/src/components/Form/Select/Select.interfaces.ts +3 -1
  147. package/src/components/Form/Select/Select.module.scss +55 -34
  148. package/src/components/Form/Select/Select.tsx +74 -23
  149. package/src/components/Form/Select/SelectService.ts +26 -10
  150. package/src/components/Icon/Icon.module.scss +12 -0
  151. package/src/components/Icon/Icon.tsx +4 -1
  152. package/src/components/Link/Link.module.scss +28 -4
  153. package/src/components/Link/Link.tsx +1 -1
  154. package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +14 -21
  155. package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +17 -13
  156. package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +43 -17
  157. package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +5 -13
  158. package/src/components/Notifications/Snackbar/interfaces.ts +15 -0
  159. package/src/components/Popover/Popover.tsx +19 -2
  160. package/src/components/Stepper/Step.tsx +2 -1
  161. package/src/components/Stepper/Stepper.tsx +0 -2
  162. package/src/components/Tooltip/Tooltip.module.scss +1 -0
  163. package/src/components/_BaseStyling_/BaseStyling.tsx +24 -22
  164. package/src/font/icomoon.eot +0 -0
  165. package/src/font/icomoon.svg +5 -2
  166. package/src/font/icomoon.ttf +0 -0
  167. package/src/font/icomoon.woff +0 -0
  168. package/src/font/selection.json +1 -1
  169. package/src/hooks/usePosition.ts +1 -1
  170. package/src/interfaces.ts +2 -2
  171. package/src/mixins.module.scss +60 -61
  172. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -64
  173. package/src/components/Button/BaseButton.test.tsx +0 -133
  174. package/src/components/Button/Button.test.tsx +0 -138
  175. package/src/components/Button/IconButton.test.tsx +0 -122
  176. package/src/components/ContextMenu/ContextMenu.test.tsx +0 -358
  177. package/src/components/DataGrid/DataGrid.test.tsx +0 -437
  178. package/src/components/DataGrid/DataGridActions/DataGridActions.test.tsx +0 -204
  179. package/src/components/DataGrid/DataGridActions/DataGridColumnsToggle.test.tsx +0 -99
  180. package/src/components/DataGrid/DataGridBody/DataGridBody.test.tsx +0 -140
  181. package/src/components/DataGrid/DataGridBody/DataGridCell.test.tsx +0 -90
  182. package/src/components/DataGrid/DataGridBody/DataGridRow.test.tsx +0 -117
  183. package/src/components/DataGrid/DataGridHeader/DataGridHeader.test.tsx +0 -276
  184. package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.test.tsx +0 -144
  185. package/src/components/Form/Checkbox/Checkbox.test.tsx +0 -308
  186. package/src/components/Form/Fieldset/Fieldset.test.tsx +0 -127
  187. package/src/components/Form/FileUpload/FileItem/FileItem.test.tsx +0 -103
  188. package/src/components/Form/FileUpload/FileUpload.test.tsx +0 -374
  189. package/src/components/Form/Form.test.tsx +0 -63
  190. package/src/components/Form/FormControl/FormControl.test.tsx +0 -98
  191. package/src/components/Form/FormGroup/FormGroup.test.tsx +0 -127
  192. package/src/components/Form/FormHelperText/FormHelperText.test.tsx +0 -84
  193. package/src/components/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +0 -94
  194. package/src/components/Form/Input/Input.test.tsx +0 -267
  195. package/src/components/Form/Label/Label.test.tsx +0 -68
  196. package/src/components/Form/Radio/Radio.test.tsx +0 -130
  197. package/src/components/Form/Select/Option.test.tsx +0 -57
  198. package/src/components/Form/Select/Select.test.tsx +0 -564
  199. package/src/components/Form/Textarea/Textarea.test.tsx +0 -124
  200. package/src/components/Form/Toggle/Toggle.test.tsx +0 -200
  201. package/src/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +0 -141
  202. package/src/components/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +0 -211
  203. package/src/components/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +0 -117
  204. package/src/components/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +0 -186
  205. package/src/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +0 -173
  206. package/src/components/Form/Wrapper/Wrapper/Wrapper.test.tsx +0 -59
  207. package/src/components/Icon/Icon.test.tsx +0 -83
  208. package/src/components/Link/Link.test.tsx +0 -197
  209. package/src/components/Notifications/Banner/Banner.test.tsx +0 -84
  210. package/src/components/Notifications/BaseModal/BaseModal.test.tsx +0 -194
  211. package/src/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +0 -74
  212. package/src/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.test.tsx +0 -71
  213. package/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +0 -74
  214. package/src/components/Notifications/Dialog/Dialog.test.tsx +0 -118
  215. package/src/components/Notifications/Dialog/DialogActions/DialogActions.test.tsx +0 -61
  216. package/src/components/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +0 -87
  217. package/src/components/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +0 -111
  218. package/src/components/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +0 -175
  219. package/src/components/Notifications/Modal/Modal.test.tsx +0 -18
  220. package/src/components/Notifications/NotificationProvider/NotificationContext.test.tsx +0 -449
  221. package/src/components/Notifications/SlideInModal/SlideInModal.test.tsx +0 -90
  222. package/src/components/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +0 -53
  223. package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +0 -63
  224. package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +0 -215
  225. package/src/components/Pagination/Pagination.test.tsx +0 -183
  226. package/src/components/Popover/Popover.test.tsx +0 -103
  227. package/src/components/ProgressBar/ProgressBar.test.tsx +0 -91
  228. package/src/components/Skeleton/Skeleton.test.tsx +0 -112
  229. package/src/components/StatusIndicator/StatusIndicator.test.tsx +0 -143
  230. package/src/components/Stepper/Stepper.test.tsx +0 -83
  231. package/src/components/Tabs/Tab.test.tsx +0 -49
  232. package/src/components/Tabs/TabButton.test.tsx +0 -65
  233. package/src/components/Tabs/Tabs.test.tsx +0 -291
  234. package/src/components/Tag/Tag.test.tsx +0 -89
  235. package/src/components/TextEllipsis/TextEllipsis.test.tsx +0 -96
  236. package/src/components/Tiles/Tile.test.tsx +0 -183
  237. package/src/components/Tiles/Tiles.test.tsx +0 -162
  238. package/src/components/Tooltip/Tooltip.test.tsx +0 -390
  239. package/src/components/Typography/Typography.test.tsx +0 -177
  240. package/src/components/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +0 -90
  241. package/src/components/Wizard/Wizard.test.tsx +0 -218
  242. package/src/components/Wizard/WizardActions/WizardActions.test.tsx +0 -187
  243. package/src/components/Wizard/WizardSteps/WizardSteps.test.tsx +0 -125
  244. package/src/components/_BaseStyling_/BaseStyling.test.tsx +0 -55
  245. package/src/hooks/useAnimation.test.tsx +0 -65
  246. package/src/hooks/useBodyClick.test.tsx +0 -55
  247. package/src/hooks/useDebouncedCallback.test.ts +0 -150
  248. package/src/hooks/useDetermineStatusIcon.test.ts +0 -28
  249. package/src/hooks/useFormSelector.test.ts +0 -56
  250. package/src/hooks/usePosition.test.tsx +0 -510
  251. package/src/hooks/useRepeater.test.tsx +0 -156
  252. package/src/hooks/useScroll.test.tsx +0 -36
  253. package/src/hooks/useSpacing.test.ts +0 -86
  254. package/src/hooks/useUploadFile.test.ts +0 -211
  255. package/src/util/helper.test.tsx +0 -403
@@ -1,143 +0,0 @@
1
- /*
2
- * Copyright 2022 OneWelcome B.V.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import React, { useEffect, useRef } from "react";
18
- import { StatusIndicator, Props } from "./StatusIndicator";
19
- import { render } from "@testing-library/react";
20
-
21
- const defaultParams: Props = {
22
- status: "active"
23
- };
24
-
25
- const createStatusIndicator = (params?: (defaultParams: Props) => Props) => {
26
- let parameters: Props = defaultParams;
27
- if (params) {
28
- parameters = params(defaultParams);
29
- }
30
- const queries = render(
31
- <StatusIndicator {...parameters} data-testid="StatusIndicator">
32
- content
33
- </StatusIndicator>
34
- );
35
- const statusIndicator = queries.getByTestId("StatusIndicator");
36
-
37
- return {
38
- ...queries,
39
- statusIndicator
40
- };
41
- };
42
-
43
- describe("StatusIndicator should render", () => {
44
- it("renders without crashing", () => {
45
- const { statusIndicator, getByText } = createStatusIndicator();
46
-
47
- expect(statusIndicator).toBeDefined();
48
- expect(getByText("content")).toBeInTheDocument();
49
- });
50
-
51
- it("passes through custom typography props", () => {
52
- const { statusIndicator, getByText } = createStatusIndicator(params => ({
53
- ...params,
54
- typographyProps: {
55
- variant: "body",
56
- children: <strong>custom children</strong>
57
- }
58
- }));
59
-
60
- expect(statusIndicator).toBeDefined();
61
- expect(getByText("custom children")).toBeInTheDocument();
62
- });
63
-
64
- it("passes through custom props", () => {
65
- const { statusIndicator } = createStatusIndicator(params => ({
66
- ...params,
67
- "aria-label": "status indicator"
68
- }));
69
-
70
- expect(statusIndicator).toBeDefined();
71
- expect(statusIndicator).toHaveAttribute("aria-label", "status indicator");
72
- });
73
-
74
- it('should set "active" class on status badge', () => {
75
- const { statusIndicator } = createStatusIndicator(params => ({
76
- ...params,
77
- status: "active"
78
- }));
79
-
80
- expect(statusIndicator.firstChild).toHaveClass("active");
81
- });
82
-
83
- it('should set "error" class on status badge', () => {
84
- const { statusIndicator } = createStatusIndicator(params => ({ ...params, status: "error" }));
85
-
86
- expect(statusIndicator.firstChild).toHaveClass("error");
87
- });
88
-
89
- it('should set "neutral" class on status badge', () => {
90
- const { statusIndicator } = createStatusIndicator(params => ({
91
- ...params,
92
- status: "neutral"
93
- }));
94
-
95
- expect(statusIndicator.firstChild).toHaveClass("neutral");
96
- });
97
-
98
- it('should pass "warning" class to status badge', () => {
99
- const { statusIndicator } = createStatusIndicator(params => ({
100
- ...params,
101
- status: "warning"
102
- }));
103
-
104
- expect(statusIndicator.firstChild).toHaveClass("warning");
105
- });
106
-
107
- it("should pass custom class to status badge", () => {
108
- const { statusIndicator } = createStatusIndicator(params => ({
109
- ...params,
110
- badgeProps: { className: "custom" }
111
- }));
112
-
113
- expect(statusIndicator.firstChild).toHaveClass("custom");
114
- });
115
- });
116
-
117
- describe("ref should work", () => {
118
- it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
119
- const ExampleComponent = ({
120
- propagateRef
121
- }: {
122
- propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
123
- }) => {
124
- const ref = useRef(null);
125
-
126
- useEffect(() => {
127
- if (ref.current) {
128
- propagateRef && propagateRef(ref);
129
- }
130
- }, [ref]);
131
-
132
- return (
133
- <StatusIndicator id="test" children="test" data-ref="testing" ref={ref} status="active" />
134
- );
135
- };
136
-
137
- const refCheck = (ref: React.RefObject<HTMLElement>) => {
138
- expect(ref.current).toHaveAttribute("data-ref", "testing");
139
- };
140
-
141
- render(<ExampleComponent propagateRef={refCheck} />);
142
- });
143
- });
@@ -1,83 +0,0 @@
1
- import React from "react";
2
- import { Stepper, Props } from "./Stepper";
3
- import { render } from "@testing-library/react";
4
-
5
- const defaultParams: Props = {
6
- steps: [],
7
- direction: "horizontal"
8
- };
9
-
10
- const createStepper = (params?: (defaultParams: Props) => Props) => {
11
- let parameters: Props = defaultParams;
12
- if (params) {
13
- parameters = params(defaultParams);
14
- }
15
- const queries = render(<Stepper {...parameters} data-testid="Stepper" />);
16
- const StepperComponent = queries.getByTestId("Stepper");
17
-
18
- return {
19
- ...queries,
20
- StepperComponent
21
- };
22
- };
23
-
24
- describe("<Stepper/> should render", () => {
25
- it("should render without crashing", () => {
26
- const { StepperComponent } = createStepper();
27
-
28
- expect(StepperComponent).toBeDefined();
29
- });
30
-
31
- it("should render given steps", () => {
32
- const { StepperComponent, getAllByText } = createStepper(params => ({
33
- ...params,
34
- steps: [
35
- {
36
- label: "Step 1",
37
- status: "waiting",
38
- caption: "Caption"
39
- },
40
- {
41
- label: "Step 2",
42
- status: "current",
43
- caption: "Caption"
44
- },
45
- {
46
- label: "Step 3",
47
- status: "done",
48
- caption: "Caption"
49
- },
50
- {
51
- label: "Step 4",
52
- status: "error",
53
- caption: "Caption"
54
- }
55
- ]
56
- }));
57
-
58
- expect(StepperComponent).toBeDefined();
59
-
60
- expect(getAllByText(/Step/i)).toHaveLength(4);
61
- expect(getAllByText(/Caption/i)).toHaveLength(4);
62
- });
63
-
64
- it("should render the horizontal stepper", () => {
65
- const { StepperComponent } = createStepper(params => ({
66
- ...params,
67
- direction: "horizontal"
68
- }));
69
-
70
- expect(StepperComponent).toBeDefined();
71
- expect(StepperComponent.classList).toContain("horizontal");
72
- });
73
-
74
- it("should render the vertical stepper", () => {
75
- const { StepperComponent } = createStepper(params => ({
76
- ...params,
77
- direction: "vertical"
78
- }));
79
-
80
- expect(StepperComponent).toBeDefined();
81
- expect(StepperComponent.classList).not.toContain("horizontal");
82
- });
83
- });
@@ -1,49 +0,0 @@
1
- /*
2
- * Copyright 2022 OneWelcome B.V.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import React from "react";
18
- import { Tab, Props } from "./Tab";
19
- import { render } from "@testing-library/react";
20
-
21
- const defaultParams: Props = {
22
- title: "Title of tab"
23
- };
24
-
25
- const createTab = (params?: (defaultParams: Props) => Props) => {
26
- let parameters: Props = defaultParams;
27
- if (params) {
28
- parameters = params(defaultParams);
29
- }
30
- const queries = render(
31
- <Tab {...parameters} data-testid="tab">
32
- tab content
33
- </Tab>
34
- );
35
- const tab = queries.getByTestId("tab");
36
-
37
- return {
38
- ...queries,
39
- tab
40
- };
41
- };
42
-
43
- describe("Tab should render", () => {
44
- it("renders without crashing", () => {
45
- const { tab } = createTab();
46
-
47
- expect(tab).toBeTruthy();
48
- });
49
- });
@@ -1,65 +0,0 @@
1
- /*
2
- * Copyright 2022 OneWelcome B.V.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import React from "react";
18
- import { Props, TabButton } from "./TabButton";
19
- import { render } from "@testing-library/react";
20
-
21
- const defaultParams: Props = {};
22
-
23
- const createTabButton = (params?: (defaultParams: Props) => Props) => {
24
- let parameters: Props = defaultParams;
25
- if (params) {
26
- parameters = params(defaultParams);
27
- }
28
- const queries = render(
29
- <TabButton {...parameters} data-testid="tabbutton">
30
- tab content
31
- </TabButton>
32
- );
33
- const tabButton = queries.getByTestId("tabbutton");
34
-
35
- return {
36
- ...queries,
37
- tabButton
38
- };
39
- };
40
-
41
- describe("Tab should render", () => {
42
- it("renders without crashing", () => {
43
- const { tabButton } = createTabButton();
44
-
45
- expect(tabButton).toBeTruthy();
46
- });
47
-
48
- it("should be focussed when prop focused is passed", () => {
49
- const { tabButton } = createTabButton(defaultParams => ({
50
- ...defaultParams,
51
- focused: true
52
- }));
53
-
54
- expect(tabButton).toHaveFocus();
55
- });
56
-
57
- it("should set class when prop className is passed", () => {
58
- const { tabButton } = createTabButton(defaultParams => ({
59
- ...defaultParams,
60
- className: "customclass"
61
- }));
62
-
63
- expect(tabButton).toHaveClass("customclass");
64
- });
65
- });
@@ -1,291 +0,0 @@
1
- /*
2
- * Copyright 2022 OneWelcome B.V.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- import React from "react";
18
- import { Tabs, Props } from "./Tabs";
19
- import { render } from "@testing-library/react";
20
- import { TabButton as Tab } from "./TabButton";
21
- import userEvent from "@testing-library/user-event";
22
- import { act } from "react-dom/test-utils";
23
-
24
- const defaultParams: Props = {
25
- children: [
26
- <Tab key="tab1" title="Tab1">
27
- Tabpanel1 content
28
- </Tab>,
29
- <Tab key="tab2" title="Tab2">
30
- Tabpanel2 content
31
- </Tab>,
32
- <Tab key="tab3" title="Tab3">
33
- Tabpanel3 content
34
- </Tab>
35
- ]
36
- };
37
-
38
- const createTabs = (params?: (defaultParams: Props) => Props) => {
39
- let parameters: Props = defaultParams;
40
- if (params) {
41
- parameters = params(defaultParams);
42
- }
43
- const queries = render(<Tabs {...parameters} data-testid="tabs"></Tabs>);
44
- const tabs = queries.getByTestId("tabs");
45
-
46
- return {
47
- ...queries,
48
- tabs
49
- };
50
- };
51
-
52
- describe("Tabs should render", () => {
53
- it("renders without crashing", () => {
54
- const { tabs } = createTabs();
55
-
56
- expect(tabs).toBeDefined();
57
- });
58
-
59
- it("renders with properties passed", () => {
60
- const { tabs } = createTabs(defaultParams => ({
61
- ...defaultParams,
62
- className: "testclass"
63
- }));
64
-
65
- expect(tabs).toHaveClass("testclass");
66
- });
67
-
68
- it("switches to tab and tabpanel when selected property is changed", () => {
69
- const { tabs } = createTabs(defaultParams => ({
70
- ...defaultParams,
71
- selected: 2
72
- }));
73
-
74
- const tablist = tabs.firstChild as HTMLDivElement;
75
- const tabpanels = tabs.lastChild as HTMLDivElement;
76
- const tabButtons = tablist.querySelectorAll(".tabbutton");
77
-
78
- const tab1 = tabButtons[0] as HTMLButtonElement;
79
- const tab3 = tabButtons[2] as HTMLButtonElement;
80
-
81
- const tabpanel1 = tabpanels.firstChild as HTMLDivElement;
82
- const tabpanel3 = tabpanels.lastChild as HTMLDivElement;
83
-
84
- expect(tab1).not.toHaveClass("selected");
85
- expect(tab3).toHaveClass("selected");
86
-
87
- expect(tabpanel1).not.toHaveClass("selected");
88
- expect(tabpanel3).toHaveClass("selected");
89
- });
90
-
91
- it("switches to tab and tabpanel when tab is clicked", async () => {
92
- const { tabs } = createTabs(defaultParams => ({
93
- ...defaultParams
94
- }));
95
-
96
- const tablist = tabs.firstChild as HTMLDivElement;
97
- const tabpanels = tabs.lastChild as HTMLDivElement;
98
- let tabButtons = tablist.querySelectorAll(".tabbutton");
99
-
100
- let tab1 = tabButtons[0] as HTMLButtonElement;
101
- let tab3 = tabButtons[2] as HTMLButtonElement;
102
-
103
- let tabpanel1 = tabpanels.firstChild as HTMLDivElement;
104
- let tabpanel3 = tabpanels.lastChild as HTMLDivElement;
105
-
106
- expect(tab1).toHaveClass("selected");
107
- expect(tab3).not.toHaveClass("selected");
108
-
109
- expect(tabpanel1).toHaveClass("selected");
110
- expect(tabpanel3).not.toHaveClass("selected");
111
-
112
- await userEvent.click(tab3);
113
-
114
- tabButtons = tablist.querySelectorAll(".tabbutton");
115
-
116
- tab1 = tabButtons[0] as HTMLButtonElement;
117
- tab3 = tabButtons[2] as HTMLButtonElement;
118
-
119
- tabpanel1 = tabpanels.firstChild as HTMLDivElement;
120
- tabpanel3 = tabpanels.lastChild as HTMLDivElement;
121
-
122
- expect(tab1).not.toHaveClass("selected");
123
- expect(tab3).toHaveClass("selected");
124
-
125
- expect(tabpanel1).not.toHaveClass("selected");
126
- expect(tabpanel3).toHaveClass("selected");
127
- });
128
-
129
- it("triggers the onTabChange when switching tabs", async () => {
130
- const onTabChangeHandler = jest.fn();
131
-
132
- const { tabs } = createTabs(defaultParams => ({
133
- ...defaultParams,
134
- onTabChange: onTabChangeHandler
135
- }));
136
-
137
- const tablist = tabs.firstChild as HTMLDivElement;
138
- const tabButtons = tablist.querySelectorAll(".tabbutton");
139
-
140
- let tab3 = tabButtons[2] as HTMLButtonElement;
141
-
142
- await userEvent.click(tab3);
143
-
144
- expect(onTabChangeHandler).toHaveBeenCalled();
145
- });
146
- });
147
-
148
- describe("Tabs should not render other children then tab components", () => {
149
- it("renders no tabs", () => {
150
- const queries = render(
151
- <Tabs data-testid="tabs">
152
- <div>wrong component 1</div>
153
- <div>wrong component 2</div>
154
- </Tabs>
155
- );
156
-
157
- const tabs = queries.getByTestId("tabs");
158
- expect(tabs).toBeDefined();
159
- expect(tabs).toBeEmptyDOMElement;
160
- });
161
- });
162
-
163
- describe("Tabs should comply with accessibility rules", () => {
164
- it("traverse through tabs with keyboard", async () => {
165
- const { tabs } = createTabs();
166
-
167
- const tablist = tabs.firstChild as HTMLDivElement;
168
- const tabpanels = tabs.lastChild as HTMLDivElement;
169
- let tabButtons = tablist.querySelectorAll(".tabbutton");
170
-
171
- let tab1 = tabButtons[0] as HTMLButtonElement;
172
- let tab3 = tabButtons[2] as HTMLButtonElement;
173
-
174
- let tabpanel1 = tabpanels.firstChild as HTMLDivElement;
175
- let tabpanel3 = tabpanels.lastChild as HTMLDivElement;
176
-
177
- act(() => {
178
- tab1.focus();
179
- });
180
-
181
- tabButtons = tablist.querySelectorAll(".tabbutton");
182
- tab1 = tabButtons[0] as HTMLButtonElement;
183
- tab3 = tabButtons[2] as HTMLButtonElement;
184
- tabpanel1 = tabpanels.firstChild as HTMLDivElement;
185
- tabpanel3 = tabpanels.lastChild as HTMLDivElement;
186
-
187
- expect(tab1).toHaveFocus();
188
- expect(tab1).toHaveClass("selected");
189
- expect(tab3).not.toHaveClass("selected");
190
- expect(tab3).not.toHaveFocus();
191
- expect(tabpanel1).toHaveClass("selected");
192
- expect(tabpanel3).not.toHaveClass("selected");
193
-
194
- await userEvent.keyboard("[ArrowLeft]");
195
- await userEvent.keyboard("[Space]");
196
-
197
- tabButtons = tablist.querySelectorAll(".tabbutton");
198
- tab1 = tabButtons[0] as HTMLButtonElement;
199
- tab3 = tabButtons[2] as HTMLButtonElement;
200
- tabpanel1 = tabpanels.firstChild as HTMLDivElement;
201
- tabpanel3 = tabpanels.lastChild as HTMLDivElement;
202
-
203
- expect(tab3).toHaveFocus();
204
- expect(tab3).toHaveClass("selected");
205
- expect(tab1).not.toHaveClass("selected");
206
- expect(tab1).not.toHaveFocus();
207
- expect(tabpanel3).toHaveClass("selected");
208
- expect(tabpanel1).not.toHaveClass("selected");
209
-
210
- await userEvent.keyboard("[ArrowRight]");
211
- await userEvent.keyboard("[Enter]");
212
-
213
- tabButtons = tablist.querySelectorAll(".tabbutton");
214
- tab1 = tabButtons[0] as HTMLButtonElement;
215
- tab3 = tabButtons[2] as HTMLButtonElement;
216
- tabpanel1 = tabpanels.firstChild as HTMLDivElement;
217
- tabpanel3 = tabpanels.lastChild as HTMLDivElement;
218
-
219
- expect(tab1).toHaveFocus();
220
- expect(tab1).toHaveClass("selected");
221
- expect(tab3).not.toHaveClass("selected");
222
- expect(tab3).not.toHaveFocus();
223
- expect(tabpanel1).toHaveClass("selected");
224
- expect(tabpanel3).not.toHaveClass("selected");
225
-
226
- await userEvent.keyboard("[End]");
227
-
228
- tabButtons = tablist.querySelectorAll(".tabbutton");
229
- tab1 = tabButtons[0] as HTMLButtonElement;
230
- tab3 = tabButtons[2] as HTMLButtonElement;
231
-
232
- expect(tab3).toHaveFocus();
233
- expect(tab3).toHaveFocus();
234
- expect(tab1).not.toHaveFocus();
235
-
236
- await userEvent.keyboard("[Home]");
237
-
238
- tabButtons = tablist.querySelectorAll(".tabbutton");
239
- tab1 = tabButtons[0] as HTMLButtonElement;
240
- tab3 = tabButtons[2] as HTMLButtonElement;
241
-
242
- expect(tab1).toHaveFocus();
243
- expect(tab1).toHaveClass("selected");
244
- expect(tab3).not.toHaveFocus();
245
-
246
- // should have no effect
247
- await userEvent.keyboard("a");
248
-
249
- tabButtons = tablist.querySelectorAll(".tabbutton");
250
- tab1 = tabButtons[0] as HTMLButtonElement;
251
- tab3 = tabButtons[2] as HTMLButtonElement;
252
-
253
- expect(tab1).toHaveFocus();
254
- expect(tab1).toHaveClass("selected");
255
- expect(tab3).not.toHaveFocus();
256
-
257
- await userEvent.keyboard("[ArrowRight]");
258
-
259
- tabButtons = tablist.querySelectorAll(".tabbutton");
260
- tab1 = tabButtons[0] as HTMLButtonElement;
261
- tab3 = tabButtons[2] as HTMLButtonElement;
262
-
263
- expect(tab1).not.toHaveFocus();
264
- expect(tab3).not.toHaveFocus();
265
- expect(tab1).not.toHaveFocus();
266
- expect(tab3).not.toHaveFocus();
267
-
268
- await userEvent.keyboard("[ArrowLeft]");
269
-
270
- tabButtons = tablist.querySelectorAll(".tabbutton");
271
- tab1 = tabButtons[0] as HTMLButtonElement;
272
- tab3 = tabButtons[2] as HTMLButtonElement;
273
-
274
- expect(tab1).toHaveFocus();
275
- expect(tab1).toHaveClass("selected");
276
- expect(tab3).not.toHaveFocus();
277
-
278
- await userEvent.keyboard("[ArrowLeft]");
279
-
280
- tabButtons = tablist.querySelectorAll(".tabbutton");
281
- tab1 = tabButtons[0] as HTMLButtonElement;
282
- tab3 = tabButtons[2] as HTMLButtonElement;
283
-
284
- act(() => {
285
- tab3.blur();
286
- });
287
-
288
- expect(tab1).not.toHaveFocus();
289
- expect(tab3).not.toHaveFocus();
290
- });
291
- });