@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,437 +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 { DataGrid, Props } from "./DataGrid";
19
- import { getAllByRole, render, queryAllByRole, getByRole } from "@testing-library/react";
20
- import { DataGridRow } from "./DataGridBody/DataGridRow";
21
- import { DataGridCell } from "./DataGridBody/DataGridCell";
22
- import { ContextMenu } from "../ContextMenu/ContextMenu";
23
- import { IconButton } from "../Button/IconButton";
24
- import { Icon, Icons } from "../Icon/Icon";
25
- import { ContextMenuItem } from "../ContextMenu/ContextMenuItem";
26
- import userEvent from "@testing-library/user-event";
27
-
28
- type DataType = { firstName: string; lastName: string; date: string };
29
-
30
- const defaultParams: Props<DataType> = {
31
- children: ({ item }) => (
32
- <DataGridRow key={item.firstName}>
33
- <DataGridCell>{item.firstName}</DataGridCell>
34
- <DataGridCell>{item.lastName}</DataGridCell>
35
- <DataGridCell>{item.date}</DataGridCell>
36
- <DataGridCell>
37
- <ContextMenu
38
- id={`consent_menu_${item.firstName}`}
39
- trigger={
40
- <IconButton title={`Actions for ${item.firstName}`} color="default">
41
- <Icon icon={Icons.EllipsisAlt} />
42
- </IconButton>
43
- }
44
- >
45
- <ContextMenuItem>Item 1</ContextMenuItem>
46
- </ContextMenu>
47
- </DataGridCell>
48
- </DataGridRow>
49
- ),
50
- headers: [
51
- { name: "firstName", headline: "First name" },
52
- { name: "lastName", headline: "Last name" },
53
- { name: "date", headline: "Date" }
54
- ],
55
- enableMultiSorting: true,
56
- data: [
57
- { firstName: "Paweł", lastName: "Napieracz", date: "12.12.1990" },
58
- { firstName: "Michał", lastName: "Górski", date: "12.12.1994" },
59
- { firstName: "Daniel", lastName: "Velden", date: "12.12.199x" },
60
- { firstName: "Jasha", lastName: "Joachimsthal", date: "12.12.198x" }
61
- ]
62
- };
63
-
64
- const createDataGrid = (params?: (defaultParams: Props<DataType>) => Props<DataType>) => {
65
- let parameters = defaultParams;
66
- if (params) {
67
- parameters = params(defaultParams);
68
- }
69
- const queries = render(<DataGrid {...parameters} data-testid="dataGrid" />);
70
- const dataGrid = queries.getByTestId("dataGrid");
71
-
72
- return {
73
- ...queries,
74
- dataGrid
75
- };
76
- };
77
-
78
- describe("DataGrid should render", () => {
79
- it("renders without crashing", () => {
80
- const rowsCount = defaultParams.data?.length!;
81
- const colsCount = defaultParams.headers?.length!;
82
- const contextMenuCellCount = 1;
83
- const { dataGrid, ...queries } = createDataGrid();
84
-
85
- expect(dataGrid).toBeDefined();
86
-
87
- expect(dataGrid.querySelector(".actions")).toBeNull();
88
-
89
- const [thead, tbody] = queries.getAllByRole("rowgroup");
90
-
91
- expect(queryAllByRole(thead, "columnheader")).toHaveLength(3);
92
- expect(queryAllByRole(thead, "cell")).toHaveLength(contextMenuCellCount);
93
- expect(queryAllByRole(thead, "button")).toHaveLength(0); //sorting should be disabled by default
94
-
95
- expect(queryAllByRole(tbody, "cell")).toHaveLength(
96
- rowsCount * (colsCount + contextMenuCellCount)
97
- );
98
- });
99
-
100
- it("renders actions buttons", () => {
101
- const { dataGrid } = createDataGrid(params => ({
102
- ...params,
103
- actions: {
104
- enableAddBtn: true,
105
- enableColumnsBtn: true,
106
- enableSearchBtn: true
107
- }
108
- }));
109
- const [addBtn, desktopColumnsBtn, mobileColumnsBtn, desktopSearchBtn, mobileSearchBtn] =
110
- getAllByRole(dataGrid.querySelector(".actions")!, "button");
111
- expect(addBtn).toHaveTextContent("Add item");
112
- expect(desktopColumnsBtn).toHaveTextContent("Columns");
113
- expect(mobileColumnsBtn).toHaveTextContent("Show/hide columns");
114
- expect(desktopSearchBtn).toHaveTextContent("Search");
115
- expect(mobileSearchBtn).toHaveTextContent("Search");
116
- });
117
-
118
- it("renders table with initialized sorting indicators", () => {
119
- const { getAllByRole } = createDataGrid(params => ({
120
- ...params,
121
- onSort: jest.fn(),
122
- initialSort: [
123
- { name: defaultParams.headers[0].name, direction: "DESC" },
124
- { name: defaultParams.headers[2].name, direction: "ASC" }
125
- ]
126
- }));
127
-
128
- const [firstNameHeader, lastNameHeader, dateHeader] = getAllByRole("columnheader");
129
- expect(firstNameHeader).toHaveAttribute("aria-sort", "descending");
130
- expect(lastNameHeader).not.toHaveAttribute("aria-sort");
131
- expect(dateHeader).toHaveAttribute("aria-sort", "ascending");
132
- });
133
-
134
- it("renders table without context menu", () => {
135
- const rowsCount = defaultParams.data?.length!;
136
- const colsCount = defaultParams.headers?.length!;
137
- const { getAllByRole } = createDataGrid(params => ({
138
- ...params,
139
- disableContextMenuColumn: true,
140
- children: ({ item }) => (
141
- <DataGridRow key={item.firstName}>
142
- <DataGridCell>{item.firstName}</DataGridCell>
143
- <DataGridCell>{item.lastName}</DataGridCell>
144
- <DataGridCell>{item.date}</DataGridCell>
145
- </DataGridRow>
146
- )
147
- }));
148
-
149
- expect(getAllByRole("columnheader")).toHaveLength(3);
150
- expect(getAllByRole("cell")).toHaveLength(rowsCount * colsCount);
151
- });
152
-
153
- it("renders loading state with skeleton loading animation on data cells and empty row on content menu cells", () => {
154
- const { ...queries } = createDataGrid(params => ({ ...params, isLoading: true }));
155
-
156
- const [_thead, tbody] = queries.getAllByRole("rowgroup");
157
- expect(
158
- getAllByRole(tbody, "cell").find((cell, index) => {
159
- const contextMenuCell = index % 4 === 3;
160
- return (
161
- !contextMenuCell && (cell.firstChild as HTMLElement).getAttribute("class") !== "loading"
162
- );
163
- })
164
- ).toBeUndefined();
165
- });
166
-
167
- it("renders empty state", () => {
168
- const emptyLabel = "emptyLabel";
169
- const { ...queries } = createDataGrid(params => ({ ...params, emptyLabel, data: [] }));
170
-
171
- const [_thead, tbody] = queries.getAllByRole("rowgroup");
172
- const rows = getAllByRole(tbody, "row");
173
- const firstRowCells = getAllByRole(rows[0], "cell");
174
- expect(firstRowCells).toHaveLength(1);
175
- expect(firstRowCells[0]).toHaveAttribute("colspan", `${defaultParams.headers.length + 1}`);
176
- expect(firstRowCells[0]).toHaveTextContent(emptyLabel);
177
- });
178
-
179
- it("renders pagination", () => {
180
- const { getByRole } = createDataGrid(params => ({
181
- ...params,
182
- paginationProps: {
183
- totalElements: 105,
184
- pageSize: 10,
185
- currentPage: 2,
186
- onPageChange: jest.fn(),
187
- onPageSizeChange: jest.fn()
188
- }
189
- }));
190
-
191
- expect(getByRole("button", { name: "previous" })).toBeDefined();
192
- expect(getByRole("button", { name: "next" })).toBeDefined();
193
- expect(getByRole("button", { name: "last" })).toBeDefined();
194
- });
195
- });
196
-
197
- describe("DataGrid should have interactive table header", () => {
198
- it("clicking table headers should call sort callback", async () => {
199
- const onSort = jest.fn();
200
- const { getAllByRole } = createDataGrid(params => ({
201
- ...params,
202
- onSort
203
- }));
204
-
205
- const [firstNameHeader, lastNameHeader, dateHeader] = getAllByRole("columnheader");
206
-
207
- await userEvent.click(getByRole(firstNameHeader, "button"));
208
- expect(onSort).toBeCalledWith([{ name: defaultParams.headers[0].name, direction: "ASC" }]);
209
-
210
- await userEvent.click(getByRole(lastNameHeader, "button"));
211
- await userEvent.click(getByRole(dateHeader, "button"));
212
- expect(onSort).toBeCalledWith([
213
- { name: defaultParams.headers[2].name, direction: "ASC" },
214
- { name: defaultParams.headers[1].name, direction: "ASC" },
215
- { name: defaultParams.headers[0].name, direction: "ASC" }
216
- ]);
217
-
218
- await userEvent.click(getByRole(firstNameHeader, "button"));
219
- expect(onSort).toBeCalledWith([
220
- { name: defaultParams.headers[0].name, direction: "DESC" },
221
- { name: defaultParams.headers[2].name, direction: "ASC" },
222
- { name: defaultParams.headers[1].name, direction: "ASC" }
223
- ]);
224
-
225
- await userEvent.click(getByRole(dateHeader, "button"));
226
- expect(onSort).toBeCalledWith([
227
- { name: defaultParams.headers[2].name, direction: "DESC" },
228
- { name: defaultParams.headers[0].name, direction: "DESC" },
229
- { name: defaultParams.headers[1].name, direction: "ASC" }
230
- ]);
231
-
232
- await userEvent.click(getByRole(dateHeader, "button"));
233
- await userEvent.click(getByRole(firstNameHeader, "button"));
234
- await userEvent.click(getByRole(lastNameHeader, "button"));
235
- expect(onSort).toBeCalledWith([{ name: defaultParams.headers[1].name, direction: "DESC" }]);
236
- expect(onSort).toBeCalledTimes(8);
237
- });
238
-
239
- it("clicking on show/hide columns popover should show/hide columns", async () => {
240
- const { getByRole, findByLabelText, ...queries } = createDataGrid(params => ({
241
- ...params,
242
- actions: { enableColumnsBtn: true }
243
- }));
244
- expect(queries.getAllByRole("columnheader")).toHaveLength(3);
245
-
246
- await userEvent.click(getByRole("button", { name: "Columns" }));
247
-
248
- const nameToggle = await findByLabelText(defaultParams.headers[1].headline);
249
- expect(nameToggle).toBeChecked();
250
- await userEvent.click(nameToggle);
251
- expect(nameToggle).not.toBeChecked();
252
- expect(getByRole("button", { name: "Close show columns dialog" })).toBeDefined();
253
-
254
- const columns = queries.getAllByRole("columnheader");
255
- expect(columns).toHaveLength(2);
256
- expect(columns[0]).toHaveTextContent(defaultParams.headers[0].headline);
257
- expect(columns[1]).toHaveTextContent(defaultParams.headers[2].headline);
258
-
259
- const rowsCount = defaultParams.data?.length!;
260
- const colsCount = defaultParams.headers.length;
261
- const hiddenColsCount = defaultParams.headers.length;
262
- const contextMenuColsCount = defaultParams.headers.length;
263
- const [_thead, tbody] = queries.getAllByRole("rowgroup");
264
- expect(getAllByRole(tbody, "cell")).toHaveLength(
265
- rowsCount * (colsCount - hiddenColsCount + contextMenuColsCount)
266
- );
267
- });
268
- });
269
-
270
- describe("ref should work", () => {
271
- it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
272
- const ExampleComponent = ({
273
- propagateRef
274
- }: {
275
- propagateRef: (ref: React.RefObject<HTMLElement>) => void;
276
- }) => {
277
- const ref = useRef(null);
278
-
279
- useEffect(() => {
280
- propagateRef(ref);
281
- }, [ref]);
282
-
283
- return <DataGrid {...defaultParams} data-ref="testing" ref={ref} />;
284
- };
285
-
286
- const refCheck = (ref: React.RefObject<HTMLElement>) => {
287
- expect(ref.current).toHaveAttribute("data-ref", "testing");
288
- };
289
-
290
- render(<ExampleComponent propagateRef={refCheck} />);
291
- });
292
- });
293
-
294
- describe("spacing should work correctly", () => {
295
- it("gives the proper paddings to the right elements", () => {
296
- const { dataGrid } = createDataGrid(defaultParams => ({
297
- ...defaultParams,
298
- spacing: { padding: 4 },
299
- paginationProps: {
300
- totalElements: 105,
301
- pageSize: 10,
302
- currentPage: 2,
303
- onPageChange: jest.fn(),
304
- onPageSizeChange: jest.fn()
305
- }
306
- }));
307
-
308
- const firstHeaderCell = dataGrid.querySelector(".table .thead .row .header-cell");
309
- const lastHeaderCell = dataGrid.querySelector(".table .thead .row td");
310
- const firstBodyCell = dataGrid.querySelector(".table tbody .row .cell");
311
- const lastBodyCell = dataGrid.querySelector(".table tbody .row td:last-of-type");
312
- const pagination = dataGrid.querySelector(".pagination-wrapper");
313
-
314
- expect(dataGrid).toHaveStyle({ "padding-top": "1rem", "padding-bottom": "1rem" });
315
- expect(firstHeaderCell).toHaveStyle({ "padding-left": "1rem" });
316
- expect(lastHeaderCell).toHaveStyle({ "padding-right": "1rem" });
317
- expect(firstBodyCell).toHaveStyle({ "padding-left": "1rem" });
318
- expect(lastBodyCell).toHaveStyle({ "padding-right": "1rem" });
319
- expect(pagination).toHaveStyle({ "padding-left": "1rem", "padding-right": "1rem" });
320
- });
321
-
322
- it("gives the proper paddings to the right elements", () => {
323
- const { dataGrid } = createDataGrid(defaultParams => ({
324
- ...defaultParams,
325
- spacing: { padding: "4 5" },
326
- paginationProps: {
327
- totalElements: 105,
328
- pageSize: 10,
329
- currentPage: 2,
330
- onPageChange: jest.fn(),
331
- onPageSizeChange: jest.fn()
332
- }
333
- }));
334
-
335
- const firstHeaderCell = dataGrid.querySelector(".table .thead .row .header-cell");
336
- const lastHeaderCell = dataGrid.querySelector(".table .thead .row td");
337
- const firstBodyCell = dataGrid.querySelector(".table tbody .row .cell");
338
- const lastBodyCell = dataGrid.querySelector(".table tbody .row td:last-of-type");
339
- const pagination = dataGrid.querySelector(".pagination-wrapper");
340
-
341
- expect(dataGrid).toHaveStyle({ "padding-top": "1rem", "padding-bottom": "1rem" });
342
- expect(firstHeaderCell).toHaveStyle({ "padding-left": "1.25rem" });
343
- expect(lastHeaderCell).toHaveStyle({ "padding-right": "1.25rem" });
344
- expect(firstBodyCell).toHaveStyle({ "padding-left": "1.25rem" });
345
- expect(lastBodyCell).toHaveStyle({ "padding-right": "1.25rem" });
346
- expect(pagination).toHaveStyle({ "padding-left": "1.25rem", "padding-right": "1.25rem" });
347
- });
348
-
349
- it("gives the proper paddings to the right elements", () => {
350
- const { dataGrid } = createDataGrid(defaultParams => ({
351
- ...defaultParams,
352
- spacing: { padding: "4 5 8" },
353
- paginationProps: {
354
- totalElements: 105,
355
- pageSize: 10,
356
- currentPage: 2,
357
- onPageChange: jest.fn(),
358
- onPageSizeChange: jest.fn()
359
- }
360
- }));
361
-
362
- const firstHeaderCell = dataGrid.querySelector(".table .thead .row .header-cell");
363
- const lastHeaderCell = dataGrid.querySelector(".table .thead .row td");
364
- const firstBodyCell = dataGrid.querySelector(".table tbody .row .cell");
365
- const lastBodyCell = dataGrid.querySelector(".table tbody .row td:last-of-type");
366
- const pagination = dataGrid.querySelector(".pagination-wrapper");
367
-
368
- expect(dataGrid).toHaveStyle({ "padding-top": "1rem", "padding-bottom": "2rem" });
369
- expect(firstHeaderCell).toHaveStyle({ "padding-left": "1.25rem" });
370
- expect(lastHeaderCell).toHaveStyle({ "padding-right": "1.25rem" });
371
- expect(firstBodyCell).toHaveStyle({ "padding-left": "1.25rem" });
372
- expect(lastBodyCell).toHaveStyle({ "padding-right": "1.25rem" });
373
- expect(pagination).toHaveStyle({ "padding-left": "1.25rem", "padding-right": "1.25rem" });
374
- });
375
-
376
- it("gives the proper paddings to the right elements", () => {
377
- const { dataGrid } = createDataGrid(defaultParams => ({
378
- ...defaultParams,
379
- spacing: { padding: "6 4 8 8" },
380
- paginationProps: {
381
- totalElements: 105,
382
- pageSize: 10,
383
- currentPage: 2,
384
- onPageChange: jest.fn(),
385
- onPageSizeChange: jest.fn()
386
- }
387
- }));
388
-
389
- const firstHeaderCell = dataGrid.querySelector(".table .thead .row .header-cell");
390
- const lastHeaderCell = dataGrid.querySelector(".table .thead .row td");
391
- const firstBodyCell = dataGrid.querySelector(".table tbody .row .cell");
392
- const lastBodyCell = dataGrid.querySelector(".table tbody .row td:last-of-type");
393
- const pagination = dataGrid.querySelector(".pagination-wrapper");
394
-
395
- expect(dataGrid).toHaveStyle({ "padding-top": "1.5rem", "padding-bottom": "2rem" });
396
- expect(firstHeaderCell).toHaveStyle({ "padding-left": "2rem" });
397
- expect(lastHeaderCell).toHaveStyle({ "padding-right": "1rem" });
398
- expect(firstBodyCell).toHaveStyle({ "padding-left": "2rem" });
399
- expect(lastBodyCell).toHaveStyle({ "padding-right": "1rem" });
400
- expect(pagination).toHaveStyle({ "padding-left": "2rem", "padding-right": "1rem" });
401
- });
402
-
403
- it("gives the proper paddings to the right elements, also with contextmenu disabled", () => {
404
- const { dataGrid } = createDataGrid(defaultParams => ({
405
- ...defaultParams,
406
- spacing: { padding: "6 4 8 8" },
407
- disableContextMenuColumn: true,
408
- paginationProps: {
409
- totalElements: 105,
410
- pageSize: 10,
411
- currentPage: 2,
412
- onPageChange: jest.fn(),
413
- onPageSizeChange: jest.fn()
414
- },
415
- children: ({ item }) => (
416
- <DataGridRow key={item.firstName}>
417
- <DataGridCell>{item.firstName}</DataGridCell>
418
- <DataGridCell>{item.lastName}</DataGridCell>
419
- <DataGridCell>{item.date}</DataGridCell>
420
- </DataGridRow>
421
- )
422
- }));
423
-
424
- const firstHeaderCell = dataGrid.querySelector(".table .thead .row .header-cell");
425
- const lastHeaderCell = dataGrid.querySelector(".table .thead .row th:last-of-type");
426
- const firstBodyCell = dataGrid.querySelector(".table tbody .row .cell");
427
- const lastBodyCell = dataGrid.querySelector(".table tbody .row td:last-of-type");
428
- const pagination = dataGrid.querySelector(".pagination-wrapper");
429
-
430
- expect(dataGrid).toHaveStyle({ "padding-top": "1.5rem", "padding-bottom": "2rem" });
431
- expect(firstHeaderCell).toHaveStyle({ "padding-left": "2rem" });
432
- expect(lastHeaderCell).toHaveStyle({ "padding-right": "1rem" });
433
- expect(firstBodyCell).toHaveStyle({ "padding-left": "2rem" });
434
- expect(lastBodyCell).toHaveStyle({ "padding-right": "1rem" });
435
- expect(pagination).toHaveStyle({ "padding-left": "2rem", "padding-right": "1rem" });
436
- });
437
- });
@@ -1,204 +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 { DataGridActions, Props } from "./DataGridActions";
19
- import { render } from "@testing-library/react";
20
- import userEvent from "@testing-library/user-event";
21
-
22
- const defaultParams: Props = {
23
- headers: [],
24
- onColumnToggled: jest.fn()
25
- };
26
-
27
- const createDataGridActions = (params?: (defaultParams: Props) => Props) => {
28
- let parameters: Props = defaultParams;
29
- if (params) {
30
- parameters = params(defaultParams);
31
- }
32
- const queries = render(<DataGridActions {...parameters} data-testid="dataGridActions" />);
33
- const dataGridActions = queries.getByTestId("dataGridActions");
34
-
35
- return {
36
- ...queries,
37
- dataGridActions
38
- };
39
- };
40
-
41
- describe("DataGridActions should render", () => {
42
- it("renders without crashing", () => {
43
- const { container } = render(<DataGridActions {...defaultParams} />);
44
-
45
- expect(container).toBeEmptyDOMElement();
46
- });
47
-
48
- it("renders all buttons", () => {
49
- const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
50
- ...params,
51
- enableAddBtn: true,
52
- enableColumnsBtn: true,
53
- enableSearchBtn: true
54
- }));
55
-
56
- expect(dataGridActions).toBeDefined();
57
- const buttons = getAllByRole("button");
58
- expect(buttons).toHaveLength(5);
59
- expect(buttons[0]).toHaveTextContent("Add item");
60
- expect(buttons[1]).toHaveTextContent("Columns");
61
- expect(buttons[2]).toHaveTextContent("Show/hide columns");
62
- expect(buttons[3]).toHaveTextContent("Search");
63
- expect(buttons[4]).toHaveTextContent("Search");
64
- });
65
-
66
- it("renders only add button", () => {
67
- const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
68
- ...params,
69
- enableAddBtn: true
70
- }));
71
-
72
- expect(dataGridActions).toBeDefined();
73
- const buttons = getAllByRole("button");
74
- expect(buttons).toHaveLength(1);
75
- expect(buttons[0]).toHaveTextContent("Add item");
76
- });
77
-
78
- it("renders only columns button", () => {
79
- const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
80
- ...params,
81
- enableColumnsBtn: true
82
- }));
83
-
84
- expect(dataGridActions).toBeDefined();
85
- const buttons = getAllByRole("button");
86
- expect(buttons).toHaveLength(2);
87
- expect(buttons[0]).toHaveTextContent("Columns");
88
- expect(buttons[1]).toHaveTextContent("Show/hide columns");
89
- });
90
-
91
- it("renders only search button", () => {
92
- const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
93
- ...params,
94
- enableAddBtn: false,
95
- enableColumnsBtn: false,
96
- enableSearchBtn: true
97
- }));
98
-
99
- expect(dataGridActions).toBeDefined();
100
- const buttons = getAllByRole("button");
101
- expect(buttons).toHaveLength(2);
102
- expect(buttons[0]).toHaveTextContent("Search");
103
- expect(buttons[1]).toHaveTextContent("Search");
104
- });
105
-
106
- it("renders buttons with overwritten props", () => {
107
- const addBtnProps = { children: "button1", title: "title1" };
108
- const columnsBtnProps = { children: "button2", title: "title2" };
109
- const searchBtnProps = { children: "button3", title: "title3" };
110
- const searchIconBtnProps = { title: "title4" };
111
- const { dataGridActions, getAllByRole } = createDataGridActions(params => ({
112
- ...params,
113
- enableAddBtn: true,
114
- enableColumnsBtn: true,
115
- enableSearchBtn: true,
116
- addBtnProps,
117
- columnsBtnProps,
118
- searchBtnProps,
119
- searchIconBtnProps
120
- }));
121
-
122
- expect(dataGridActions).toBeDefined();
123
- const [addBtn, desktopColumnsBtn, mobileColumnsBtn, desktopSearchBtn, mobileSearchBtn] =
124
- getAllByRole("button");
125
- expect(addBtn).toHaveTextContent(addBtnProps.children);
126
- expect(addBtn).toHaveAttribute("title", addBtnProps.title);
127
- expect(desktopColumnsBtn).toHaveTextContent(columnsBtnProps.children);
128
- expect(desktopColumnsBtn).toHaveAttribute("title", columnsBtnProps.title);
129
- expect(mobileColumnsBtn).toHaveTextContent(columnsBtnProps.title);
130
- expect(desktopSearchBtn).toHaveTextContent(searchBtnProps.children);
131
- expect(desktopSearchBtn).toHaveAttribute("title", searchBtnProps.title);
132
- expect(mobileSearchBtn).toHaveTextContent(searchIconBtnProps.title);
133
- });
134
- });
135
-
136
- describe("DataGridActions should be interactive", () => {
137
- it("clicking on columns button opens show/hide columns popover", async () => {
138
- const toggleHeader = { name: "test", headline: "Label" };
139
- const { getAllByRole, findByLabelText } = createDataGridActions(params => ({
140
- ...params,
141
- enableColumnsBtn: true,
142
- headers: [toggleHeader]
143
- }));
144
-
145
- await userEvent.click(getAllByRole("button")[0]);
146
-
147
- const toggle = await findByLabelText(toggleHeader.headline);
148
- expect(toggle).toBeDefined();
149
- expect(toggle).toBeChecked();
150
-
151
- await userEvent.click(toggle);
152
- expect(defaultParams.onColumnToggled).toBeCalledWith(toggleHeader.name);
153
- });
154
-
155
- it("clicking on add button runs callback", async () => {
156
- const onClick = jest.fn();
157
- const { getAllByRole } = createDataGridActions(params => ({
158
- ...params,
159
- enableAddBtn: true,
160
- addBtnProps: { onClick }
161
- }));
162
-
163
- await userEvent.click(getAllByRole("button")[0]);
164
-
165
- expect(onClick).toBeCalledTimes(1);
166
- });
167
-
168
- it("clicking on search button runs callback", async () => {
169
- const onClick = jest.fn();
170
- const { getAllByRole } = createDataGridActions(params => ({
171
- ...params,
172
- enableSearchBtn: true,
173
- searchBtnProps: { onClick }
174
- }));
175
-
176
- await userEvent.click(getAllByRole("button")[0]);
177
-
178
- expect(onClick).toBeCalledTimes(1);
179
- });
180
- });
181
-
182
- describe("ref should work", () => {
183
- it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
184
- const ExampleComponent = ({
185
- propagateRef
186
- }: {
187
- propagateRef: (ref: React.RefObject<HTMLElement>) => void;
188
- }) => {
189
- const ref = useRef(null);
190
-
191
- useEffect(() => {
192
- propagateRef(ref);
193
- }, [ref]);
194
-
195
- return <DataGridActions {...defaultParams} data-ref="testing" enableAddBtn ref={ref} />;
196
- };
197
-
198
- const refCheck = (ref: React.RefObject<HTMLElement>) => {
199
- expect(ref.current).toHaveAttribute("data-ref", "testing");
200
- };
201
-
202
- render(<ExampleComponent propagateRef={refCheck} />);
203
- });
204
- });