@lumx/react 3.3.1-alpha.0 → 3.3.1

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 (117) hide show
  1. package/_internal/ClickAwayProvider.js.map +1 -1
  2. package/_internal/types.d.ts +0 -2
  3. package/index.d.ts +2 -0
  4. package/index.js +347 -75
  5. package/index.js.map +1 -1
  6. package/package.json +23 -19
  7. package/src/components/autocomplete/Autocomplete.test.tsx +55 -142
  8. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +37 -75
  9. package/src/components/autocomplete/__mockData__/index.ts +6 -1
  10. package/src/components/badge/Badge.test.tsx +20 -64
  11. package/src/components/button/Button.test.tsx +44 -121
  12. package/src/components/button/ButtonGroup.test.tsx +16 -39
  13. package/src/components/button/IconButton.stories.tsx +7 -0
  14. package/src/components/button/IconButton.test.tsx +37 -78
  15. package/src/components/button/IconButton.tsx +8 -1
  16. package/src/components/checkbox/Checkbox.test.tsx +62 -67
  17. package/src/components/chip/Chip.test.tsx +89 -139
  18. package/src/components/chip/ChipGroup.test.tsx +27 -10
  19. package/src/components/date-picker/DatePicker.test.tsx +15 -23
  20. package/src/components/date-picker/DatePickerControlled.test.tsx +24 -20
  21. package/src/components/date-picker/DatePickerField.test.tsx +43 -27
  22. package/src/components/dialog/Dialog.test.tsx +36 -35
  23. package/src/components/divider/Divider.test.tsx +23 -69
  24. package/src/components/dropdown/Dropdown.test.tsx +30 -61
  25. package/src/components/expansion-panel/ExpansionPanel.test.tsx +12 -8
  26. package/src/components/flag/Flag.test.tsx +28 -53
  27. package/src/components/generic-block/GenericBlock.test.tsx +93 -89
  28. package/src/components/grid-column/GridColumn.stories.tsx +3 -3
  29. package/src/components/icon/Icon.test.tsx +80 -64
  30. package/src/components/index.ts +0 -2
  31. package/src/components/inline-list/InlineList.test.tsx +30 -17
  32. package/src/components/input-helper/InputHelper.test.tsx +21 -81
  33. package/src/components/input-label/InputLabel.test.tsx +19 -61
  34. package/src/components/lightbox/Lightbox.test.tsx +3 -2
  35. package/src/components/link/Link.test.tsx +47 -31
  36. package/src/components/link-preview/LinkPreview.test.tsx +51 -51
  37. package/src/components/message/Message.test.tsx +31 -52
  38. package/src/components/mosaic/Mosaic.test.tsx +56 -72
  39. package/src/components/notification/Notification.test.tsx +51 -82
  40. package/src/components/popover/Popover.tsx +7 -9
  41. package/src/components/progress-tracker/ProgressTracker.test.tsx +20 -33
  42. package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +61 -36
  43. package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +19 -109
  44. package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +21 -58
  45. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +1 -1
  46. package/src/components/radio-button/RadioButton.test.tsx +78 -92
  47. package/src/components/radio-button/RadioGroup.test.tsx +13 -59
  48. package/src/components/select/Select.test.tsx +115 -284
  49. package/src/components/select/SelectMultiple.stories.tsx +105 -2
  50. package/src/components/select/SelectMultiple.test.tsx +126 -322
  51. package/src/components/select/WithSelectContext.tsx +10 -4
  52. package/src/components/side-navigation/SideNavigation.test.tsx +22 -35
  53. package/src/components/side-navigation/SideNavigationItem.test.tsx +72 -139
  54. package/src/components/switch/Switch.test.tsx +70 -149
  55. package/src/components/table/Table.test.tsx +2 -0
  56. package/src/components/table/TableBody.test.tsx +18 -8
  57. package/src/components/table/TableCell.test.tsx +34 -9
  58. package/src/components/table/TableHeader.test.tsx +18 -8
  59. package/src/components/table/TableRow.test.tsx +28 -8
  60. package/src/components/tabs/Tab.test.tsx +27 -96
  61. package/src/components/tabs/TabList.test.tsx +21 -56
  62. package/src/components/tabs/TabPanel.test.tsx +20 -55
  63. package/src/components/tabs/TabPanel.tsx +1 -1
  64. package/src/components/tabs/TabProvider.test.tsx +158 -37
  65. package/src/components/tabs/test-utils.ts +39 -0
  66. package/src/components/text-field/TextField.stories.tsx +14 -5
  67. package/src/components/text-field/TextField.test.tsx +54 -8
  68. package/src/components/text-field/TextField.tsx +49 -5
  69. package/src/components/tooltip/Tooltip.test.tsx +134 -75
  70. package/src/components/tooltip/useInjectTooltipRef.tsx +9 -2
  71. package/src/components/uploader/Uploader.test.tsx +60 -48
  72. package/src/components/user-block/UserBlock.test.tsx +69 -13
  73. package/src/hooks/useFocusTrap.ts +2 -2
  74. package/src/testing/utils/commonTestsSuiteRTL.ts +18 -8
  75. package/src/testing/utils/index.ts +0 -1
  76. package/src/utils/flattenChildren.ts +5 -0
  77. package/src/components/autocomplete/__snapshots__/Autocomplete.test.tsx.snap +0 -213
  78. package/src/components/autocomplete/__snapshots__/AutocompleteMultiple.test.tsx.snap +0 -88
  79. package/src/components/badge/__snapshots__/Badge.test.tsx.snap +0 -11
  80. package/src/components/button/ButtonRoot.test.tsx +0 -203
  81. package/src/components/button/__snapshots__/Button.test.tsx.snap +0 -96
  82. package/src/components/button/__snapshots__/ButtonGroup.test.tsx.snap +0 -22
  83. package/src/components/button/__snapshots__/ButtonRoot.test.tsx.snap +0 -160
  84. package/src/components/button/__snapshots__/IconButton.test.tsx.snap +0 -83
  85. package/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +0 -141
  86. package/src/components/chip/__snapshots__/Chip.test.tsx.snap +0 -12
  87. package/src/components/chip/__snapshots__/ChipGroup.test.tsx.snap +0 -29
  88. package/src/components/date-picker/__snapshots__/DatePicker.test.tsx.snap +0 -22
  89. package/src/components/date-picker/__snapshots__/DatePickerControlled.test.tsx.snap +0 -597
  90. package/src/components/date-picker/__snapshots__/DatePickerField.test.tsx.snap +0 -43
  91. package/src/components/divider/__snapshots__/Divider.test.tsx.snap +0 -9
  92. package/src/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +0 -35
  93. package/src/components/icon/__snapshots__/Icon.test.tsx.snap +0 -49
  94. package/src/components/input-helper/__snapshots__/InputHelper.test.tsx.snap +0 -9
  95. package/src/components/input-label/__snapshots__/InputLabel.test.tsx.snap +0 -10
  96. package/src/components/link/__snapshots__/Link.test.tsx.snap +0 -29
  97. package/src/components/message/__snapshots__/Message.test.tsx.snap +0 -15
  98. package/src/components/notification/__snapshots__/Notification.test.tsx.snap +0 -34
  99. package/src/components/progress-tracker/__snapshots__/ProgressTracker.test.tsx.snap +0 -41
  100. package/src/components/progress-tracker/__snapshots__/ProgressTrackerStep.test.tsx.snap +0 -141
  101. package/src/components/progress-tracker/__snapshots__/ProgressTrackerStepPanel.test.tsx.snap +0 -25
  102. package/src/components/radio-button/__snapshots__/RadioButton.test.tsx.snap +0 -113
  103. package/src/components/radio-button/__snapshots__/RadioGroup.test.tsx.snap +0 -26
  104. package/src/components/select/__snapshots__/Select.test.tsx.snap +0 -43
  105. package/src/components/select/__snapshots__/SelectMultiple.test.tsx.snap +0 -87
  106. package/src/components/side-navigation/__snapshots__/SideNavigation.test.tsx.snap +0 -7
  107. package/src/components/side-navigation/__snapshots__/SideNavigationItem.test.tsx.snap +0 -30
  108. package/src/components/switch/__snapshots__/Switch.test.tsx.snap +0 -179
  109. package/src/components/tabs/__snapshots__/Tab.test.tsx.snap +0 -62
  110. package/src/components/tabs/__snapshots__/TabList.test.tsx.snap +0 -22
  111. package/src/components/tabs/__snapshots__/TabPanel.test.tsx.snap +0 -25
  112. package/src/components/tabs/test.mocks.ts +0 -33
  113. package/src/components/text-field/__snapshots__/TextField.test.tsx.snap +0 -42
  114. package/src/components/tooltip/__snapshots__/Tooltip.test.tsx.snap +0 -233
  115. package/src/components/uploader/__snapshots__/Uploader.test.tsx.snap +0 -14
  116. package/src/testing/utils/commonTestsSuite.ts +0 -71
  117. package/src/utils/flattenChildren.test.tsx +0 -58
@@ -1,71 +0,0 @@
1
- import { ReactWrapper, ShallowWrapper } from 'enzyme';
2
- import 'jest-enzyme';
3
-
4
- import isArray from 'lodash/isArray';
5
- import isEmpty from 'lodash/isEmpty';
6
-
7
- import { GenericProps } from '@lumx/react/utils/type';
8
-
9
- export type Wrapper = ShallowWrapper | ReactWrapper;
10
-
11
- /**
12
- * Defines what is always returned by the setup function.
13
- * Note that `props` should be retyped in the specific interface extending this one.
14
- */
15
- export interface CommonSetup {
16
- props: GenericProps;
17
- wrapper: Wrapper;
18
- }
19
-
20
- /**
21
- * Run the common tests suite: CSS class forwarding, prop forwarding, ...
22
- *
23
- * @param setup The setup function.
24
- * @param tests The tests to enable.
25
- * The key is the name of the test, the value is the name of the wrapper in the object returned
26
- * by the `setup` function.
27
- * @param params The params that can be used by the tests.
28
- */
29
- export function commonTestsSuite(
30
- setup: (props?: GenericProps, shallowRendering?: boolean) => CommonSetup,
31
- { ...tests }: { className?: string | string[]; prop?: string | string[] },
32
- { ...params }: GenericProps,
33
- ): void {
34
- if (isEmpty(tests)) {
35
- return;
36
- }
37
-
38
- describe('Common tests suite', () => {
39
- if (tests.className !== undefined && !isEmpty(tests.className)) {
40
- it('should forward any CSS class', () => {
41
- const modifiedProps: GenericProps = {
42
- className: 'component component--is-tested',
43
- };
44
-
45
- const wrappers: any = setup(modifiedProps);
46
-
47
- const wrappersToTest = isArray(tests.className)
48
- ? tests.className
49
- : [tests.className as string, tests.className as string];
50
- expect(wrappers[wrappersToTest[0]]).toHaveClassName(params.className as string);
51
- expect(wrappers[wrappersToTest[1]]).toHaveClassName(modifiedProps.className as string);
52
- });
53
- }
54
-
55
- if (tests.prop !== undefined && !isEmpty(tests.prop)) {
56
- it('should forward any other prop', () => {
57
- const testedProp: string = params.prop || 'winter';
58
- const modifiedProps: GenericProps = {
59
- [testedProp]: params.propValue || 'is coming',
60
- };
61
-
62
- const wrappers: any = setup(modifiedProps);
63
-
64
- const wrappersToTest = isArray(tests.prop) ? tests.prop : [tests.prop as string];
65
- wrappersToTest.forEach((wrapper) => {
66
- expect(wrappers[wrapper]).toHaveProp(testedProp, modifiedProps[testedProp]);
67
- });
68
- });
69
- }
70
- });
71
- }
@@ -1,58 +0,0 @@
1
- import { flattenChildren } from '@lumx/react/utils/flattenChildren';
2
- import { mount } from 'enzyme';
3
- import React from 'react';
4
-
5
- const Comp = ({ children }: any) => children;
6
-
7
- describe('flattenChildren', () => {
8
- it('should flatten children in arrays or fragments', () => {
9
- const nodes = (
10
- <Comp>
11
- {flattenChildren(
12
- <>
13
- <Comp>foo</Comp>
14
- {[
15
- <Comp key="1">bar</Comp>,
16
- <Comp key="2">{['baz', <Comp key="1">qux</Comp>]}</Comp>,
17
- ['quux', <Comp key="2">quuz</Comp>],
18
- ]}
19
- corge
20
- <>grault</>
21
- </>,
22
- )}
23
- </Comp>
24
- );
25
- expect(mount(nodes)).toMatchInlineSnapshot(`
26
- <Comp>
27
- <Comp
28
- key=".0..0"
29
- >
30
- foo
31
- </Comp>
32
- <Comp
33
- key=".0..1:$1"
34
- >
35
- bar
36
- </Comp>
37
- <Comp
38
- key=".0..1:$2"
39
- >
40
- baz
41
- <Comp
42
- key="1"
43
- >
44
- qux
45
- </Comp>
46
- </Comp>
47
- quux
48
- <Comp
49
- key=".0..1:2:$2"
50
- >
51
- quuz
52
- </Comp>
53
- corge
54
- grault
55
- </Comp>
56
- `);
57
- });
58
- });