@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.
- package/_internal/ClickAwayProvider.js.map +1 -1
- package/_internal/types.d.ts +0 -2
- package/index.d.ts +2 -0
- package/index.js +347 -75
- package/index.js.map +1 -1
- package/package.json +23 -19
- package/src/components/autocomplete/Autocomplete.test.tsx +55 -142
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +37 -75
- package/src/components/autocomplete/__mockData__/index.ts +6 -1
- package/src/components/badge/Badge.test.tsx +20 -64
- package/src/components/button/Button.test.tsx +44 -121
- package/src/components/button/ButtonGroup.test.tsx +16 -39
- package/src/components/button/IconButton.stories.tsx +7 -0
- package/src/components/button/IconButton.test.tsx +37 -78
- package/src/components/button/IconButton.tsx +8 -1
- package/src/components/checkbox/Checkbox.test.tsx +62 -67
- package/src/components/chip/Chip.test.tsx +89 -139
- package/src/components/chip/ChipGroup.test.tsx +27 -10
- package/src/components/date-picker/DatePicker.test.tsx +15 -23
- package/src/components/date-picker/DatePickerControlled.test.tsx +24 -20
- package/src/components/date-picker/DatePickerField.test.tsx +43 -27
- package/src/components/dialog/Dialog.test.tsx +36 -35
- package/src/components/divider/Divider.test.tsx +23 -69
- package/src/components/dropdown/Dropdown.test.tsx +30 -61
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +12 -8
- package/src/components/flag/Flag.test.tsx +28 -53
- package/src/components/generic-block/GenericBlock.test.tsx +93 -89
- package/src/components/grid-column/GridColumn.stories.tsx +3 -3
- package/src/components/icon/Icon.test.tsx +80 -64
- package/src/components/index.ts +0 -2
- package/src/components/inline-list/InlineList.test.tsx +30 -17
- package/src/components/input-helper/InputHelper.test.tsx +21 -81
- package/src/components/input-label/InputLabel.test.tsx +19 -61
- package/src/components/lightbox/Lightbox.test.tsx +3 -2
- package/src/components/link/Link.test.tsx +47 -31
- package/src/components/link-preview/LinkPreview.test.tsx +51 -51
- package/src/components/message/Message.test.tsx +31 -52
- package/src/components/mosaic/Mosaic.test.tsx +56 -72
- package/src/components/notification/Notification.test.tsx +51 -82
- package/src/components/popover/Popover.tsx +7 -9
- package/src/components/progress-tracker/ProgressTracker.test.tsx +20 -33
- package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +61 -36
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +19 -109
- package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +21 -58
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +1 -1
- package/src/components/radio-button/RadioButton.test.tsx +78 -92
- package/src/components/radio-button/RadioGroup.test.tsx +13 -59
- package/src/components/select/Select.test.tsx +115 -284
- package/src/components/select/SelectMultiple.stories.tsx +105 -2
- package/src/components/select/SelectMultiple.test.tsx +126 -322
- package/src/components/select/WithSelectContext.tsx +10 -4
- package/src/components/side-navigation/SideNavigation.test.tsx +22 -35
- package/src/components/side-navigation/SideNavigationItem.test.tsx +72 -139
- package/src/components/switch/Switch.test.tsx +70 -149
- package/src/components/table/Table.test.tsx +2 -0
- package/src/components/table/TableBody.test.tsx +18 -8
- package/src/components/table/TableCell.test.tsx +34 -9
- package/src/components/table/TableHeader.test.tsx +18 -8
- package/src/components/table/TableRow.test.tsx +28 -8
- package/src/components/tabs/Tab.test.tsx +27 -96
- package/src/components/tabs/TabList.test.tsx +21 -56
- package/src/components/tabs/TabPanel.test.tsx +20 -55
- package/src/components/tabs/TabPanel.tsx +1 -1
- package/src/components/tabs/TabProvider.test.tsx +158 -37
- package/src/components/tabs/test-utils.ts +39 -0
- package/src/components/text-field/TextField.stories.tsx +14 -5
- package/src/components/text-field/TextField.test.tsx +54 -8
- package/src/components/text-field/TextField.tsx +49 -5
- package/src/components/tooltip/Tooltip.test.tsx +134 -75
- package/src/components/tooltip/useInjectTooltipRef.tsx +9 -2
- package/src/components/uploader/Uploader.test.tsx +60 -48
- package/src/components/user-block/UserBlock.test.tsx +69 -13
- package/src/hooks/useFocusTrap.ts +2 -2
- package/src/testing/utils/commonTestsSuiteRTL.ts +18 -8
- package/src/testing/utils/index.ts +0 -1
- package/src/utils/flattenChildren.ts +5 -0
- package/src/components/autocomplete/__snapshots__/Autocomplete.test.tsx.snap +0 -213
- package/src/components/autocomplete/__snapshots__/AutocompleteMultiple.test.tsx.snap +0 -88
- package/src/components/badge/__snapshots__/Badge.test.tsx.snap +0 -11
- package/src/components/button/ButtonRoot.test.tsx +0 -203
- package/src/components/button/__snapshots__/Button.test.tsx.snap +0 -96
- package/src/components/button/__snapshots__/ButtonGroup.test.tsx.snap +0 -22
- package/src/components/button/__snapshots__/ButtonRoot.test.tsx.snap +0 -160
- package/src/components/button/__snapshots__/IconButton.test.tsx.snap +0 -83
- package/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +0 -141
- package/src/components/chip/__snapshots__/Chip.test.tsx.snap +0 -12
- package/src/components/chip/__snapshots__/ChipGroup.test.tsx.snap +0 -29
- package/src/components/date-picker/__snapshots__/DatePicker.test.tsx.snap +0 -22
- package/src/components/date-picker/__snapshots__/DatePickerControlled.test.tsx.snap +0 -597
- package/src/components/date-picker/__snapshots__/DatePickerField.test.tsx.snap +0 -43
- package/src/components/divider/__snapshots__/Divider.test.tsx.snap +0 -9
- package/src/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +0 -35
- package/src/components/icon/__snapshots__/Icon.test.tsx.snap +0 -49
- package/src/components/input-helper/__snapshots__/InputHelper.test.tsx.snap +0 -9
- package/src/components/input-label/__snapshots__/InputLabel.test.tsx.snap +0 -10
- package/src/components/link/__snapshots__/Link.test.tsx.snap +0 -29
- package/src/components/message/__snapshots__/Message.test.tsx.snap +0 -15
- package/src/components/notification/__snapshots__/Notification.test.tsx.snap +0 -34
- package/src/components/progress-tracker/__snapshots__/ProgressTracker.test.tsx.snap +0 -41
- package/src/components/progress-tracker/__snapshots__/ProgressTrackerStep.test.tsx.snap +0 -141
- package/src/components/progress-tracker/__snapshots__/ProgressTrackerStepPanel.test.tsx.snap +0 -25
- package/src/components/radio-button/__snapshots__/RadioButton.test.tsx.snap +0 -113
- package/src/components/radio-button/__snapshots__/RadioGroup.test.tsx.snap +0 -26
- package/src/components/select/__snapshots__/Select.test.tsx.snap +0 -43
- package/src/components/select/__snapshots__/SelectMultiple.test.tsx.snap +0 -87
- package/src/components/side-navigation/__snapshots__/SideNavigation.test.tsx.snap +0 -7
- package/src/components/side-navigation/__snapshots__/SideNavigationItem.test.tsx.snap +0 -30
- package/src/components/switch/__snapshots__/Switch.test.tsx.snap +0 -179
- package/src/components/tabs/__snapshots__/Tab.test.tsx.snap +0 -62
- package/src/components/tabs/__snapshots__/TabList.test.tsx.snap +0 -22
- package/src/components/tabs/__snapshots__/TabPanel.test.tsx.snap +0 -25
- package/src/components/tabs/test.mocks.ts +0 -33
- package/src/components/text-field/__snapshots__/TextField.test.tsx.snap +0 -42
- package/src/components/tooltip/__snapshots__/Tooltip.test.tsx.snap +0 -233
- package/src/components/uploader/__snapshots__/Uploader.test.tsx.snap +0 -14
- package/src/testing/utils/commonTestsSuite.ts +0 -71
- 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
|
-
});
|