@lumx/react 3.20.1-alpha.3 → 3.20.1-alpha.5
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/index.js.map +1 -1
- package/index.d.ts +34 -35
- package/index.js +215 -212
- package/index.js.map +1 -1
- package/package.json +12 -10
- package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
- package/src/components/alert-dialog/AlertDialog.test.tsx +4 -3
- package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
- package/src/components/autocomplete/Autocomplete.test.tsx +5 -3
- package/src/components/autocomplete/Autocomplete.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +2 -0
- package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
- package/src/components/avatar/Avatar.stories.tsx +2 -0
- package/src/components/avatar/Avatar.test.tsx +2 -0
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.stories.tsx +1 -0
- package/src/components/badge/Badge.test.tsx +2 -0
- package/src/components/badge/Badge.tsx +1 -1
- package/src/components/badge/BadgeWrapper.stories.tsx +1 -0
- package/src/components/badge/BadgeWrapper.test.tsx +2 -0
- package/src/components/badge/BadgeWrapper.tsx +1 -1
- package/src/components/button/Button.stories.tsx +1 -0
- package/src/components/button/Button.test.tsx +11 -9
- package/src/components/button/Button.tsx +2 -0
- package/src/components/button/ButtonGroup.stories.tsx +2 -0
- package/src/components/button/ButtonGroup.test.tsx +2 -0
- package/src/components/button/ButtonGroup.tsx +2 -0
- package/src/components/button/ButtonRoot.tsx +37 -7
- package/src/components/button/IconButton.test.tsx +2 -0
- package/src/components/button/IconButton.tsx +2 -0
- package/src/components/checkbox/Checkbox.test.tsx +5 -3
- package/src/components/chip/Chip.stories.tsx +2 -0
- package/src/components/chip/Chip.test.tsx +19 -19
- package/src/components/chip/Chip.tsx +1 -1
- package/src/components/chip/ChipGroup.stories.tsx +2 -0
- package/src/components/chip/ChipGroup.test.tsx +2 -0
- package/src/components/chip/ChipGroup.tsx +1 -1
- package/src/components/comment-block/CommentBlock.stories.tsx +1 -0
- package/src/components/comment-block/CommentBlock.test.tsx +1 -0
- package/src/components/comment-block/CommentBlock.tsx +1 -1
- package/src/components/date-picker/DatePicker.test.tsx +5 -3
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.test.tsx +8 -6
- package/src/components/date-picker/DatePickerField.test.tsx +5 -3
- package/src/components/dialog/Dialog.test.tsx +6 -4
- package/src/components/divider/Divider.test.tsx +2 -0
- package/src/components/divider/Divider.tsx +2 -0
- package/src/components/drag-handle/DragHandle.test.tsx +2 -0
- package/src/components/drag-handle/DragHandle.tsx +2 -0
- package/src/components/dropdown/Dropdown.stories.tsx +1 -1
- package/src/components/dropdown/Dropdown.test.tsx +3 -3
- package/src/components/dropdown/Dropdown.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +7 -6
- package/src/components/flag/Flag.test.tsx +2 -0
- package/src/components/flag/Flag.tsx +2 -0
- package/src/components/flex-box/FlexBox.stories.tsx +2 -0
- package/src/components/flex-box/FlexBox.test.tsx +1 -0
- package/src/components/flex-box/FlexBox.tsx +1 -1
- package/src/components/generic-block/GenericBlock.test.tsx +1 -1
- package/src/components/grid/Grid.tsx +2 -0
- package/src/components/grid/GridItem.tsx +2 -0
- package/src/components/grid-column/GridColumn.stories.tsx +1 -0
- package/src/components/grid-column/GridColumn.test.jsx +2 -0
- package/src/components/grid-column/GridColumn.tsx +1 -1
- package/src/components/heading/Heading.stories.tsx +1 -0
- package/src/components/heading/Heading.test.tsx +2 -0
- package/src/components/heading/Heading.tsx +2 -0
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/icon/Icon.stories.tsx +4 -30
- package/src/components/icon/Icon.test.tsx +4 -85
- package/src/components/icon/Icon.tsx +2 -0
- package/src/components/image-block/ImageBlock.stories.tsx +2 -0
- package/src/components/image-block/ImageBlock.test.tsx +1 -0
- package/src/components/image-block/ImageBlock.tsx +1 -1
- package/src/components/image-block/ImageCaption.tsx +1 -1
- package/src/components/image-lightbox/ImageLightbox.stories.tsx +1 -0
- package/src/components/image-lightbox/ImageLightbox.test.tsx +9 -11
- package/src/components/image-lightbox/types.ts +2 -0
- package/src/components/inline-list/InlineList.stories.tsx +1 -0
- package/src/components/inline-list/InlineList.test.tsx +2 -0
- package/src/components/inline-list/InlineList.tsx +1 -1
- package/src/components/input-helper/InputHelper.test.tsx +2 -0
- package/src/components/input-helper/InputHelper.tsx +1 -1
- package/src/components/input-label/InputLabel.stories.tsx +2 -0
- package/src/components/input-label/InputLabel.test.tsx +2 -0
- package/src/components/input-label/InputLabel.tsx +1 -1
- package/src/components/lightbox/Lightbox.test.tsx +2 -0
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link/Link.stories.tsx +1 -0
- package/src/components/link/Link.test.tsx +13 -13
- package/src/components/link/Link.tsx +22 -9
- package/src/components/link-preview/LinkPreview.test.tsx +2 -0
- package/src/components/link-preview/LinkPreview.tsx +2 -0
- package/src/components/list/List.stories.tsx +1 -1
- package/src/components/list/List.test.tsx +2 -0
- package/src/components/list/List.tsx +1 -1
- package/src/components/list/ListDivider.test.tsx +2 -0
- package/src/components/list/ListDivider.tsx +2 -0
- package/src/components/list/ListItem.test.tsx +7 -5
- package/src/components/list/ListItem.tsx +1 -1
- package/src/components/list/ListSubheader.test.tsx +2 -0
- package/src/components/list/ListSubheader.tsx +1 -1
- package/src/components/message/Message.test.tsx +2 -1
- package/src/components/message/Message.tsx +1 -1
- package/src/components/mosaic/Mosaic.test.tsx +5 -3
- package/src/components/mosaic/Mosaic.tsx +1 -1
- package/src/components/navigation/Navigation.stories.tsx +2 -0
- package/src/components/navigation/Navigation.test.tsx +2 -0
- package/src/components/navigation/Navigation.tsx +2 -0
- package/src/components/navigation/NavigationItem.test.tsx +2 -0
- package/src/components/navigation/NavigationItem.tsx +11 -7
- package/src/components/navigation/NavigationSection.test.tsx +2 -0
- package/src/components/navigation/NavigationSection.tsx +4 -5
- package/src/components/notification/Notification.test.tsx +5 -4
- package/src/components/notification/Notification.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +2 -0
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover/usePopoverStyle.tsx +1 -1
- package/src/components/popover-dialog/PopoverDialog.test.tsx +2 -1
- package/src/components/popover-dialog/PopoverDialog.tsx +2 -0
- package/src/components/post-block/PostBlock.test.tsx +2 -0
- package/src/components/post-block/PostBlock.tsx +1 -1
- package/src/components/progress/Progress.tsx +2 -0
- package/src/components/progress/ProgressCircular.stories.tsx +1 -0
- package/src/components/progress/ProgressCircular.test.tsx +2 -0
- package/src/components/progress/ProgressCircular.tsx +2 -0
- package/src/components/progress/ProgressLinear.test.tsx +2 -0
- package/src/components/progress/ProgressLinear.tsx +2 -0
- package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
- package/src/components/progress-tracker/ProgressTracker.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +2 -0
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -0
- package/src/components/radio-button/RadioButton.test.tsx +5 -3
- package/src/components/radio-button/RadioButton.tsx +1 -1
- package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
- package/src/components/radio-button/RadioGroup.test.tsx +2 -0
- package/src/components/radio-button/RadioGroup.tsx +1 -1
- package/src/components/select/Select.stories.tsx +1 -1
- package/src/components/select/Select.test.tsx +9 -8
- package/src/components/select/Select.tsx +1 -1
- package/src/components/select/SelectMultiple.stories.tsx +1 -1
- package/src/components/select/SelectMultiple.test.tsx +7 -5
- package/src/components/select/SelectMultiple.tsx +1 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/select/constants.ts +1 -1
- package/src/components/side-navigation/SideNavigation.test.tsx +2 -0
- package/src/components/side-navigation/SideNavigation.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +4 -2
- package/src/components/side-navigation/SideNavigationItem.tsx +28 -23
- package/src/components/skeleton/SkeletonCircle.test.tsx +2 -0
- package/src/components/skeleton/SkeletonCircle.tsx +2 -0
- package/src/components/skeleton/SkeletonRectangle.test.tsx +2 -0
- package/src/components/skeleton/SkeletonRectangle.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.stories.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.test.tsx +2 -0
- package/src/components/skeleton/SkeletonTypography.tsx +1 -1
- package/src/components/slider/Slider.test.tsx +3 -1
- package/src/components/slider/Slider.tsx +1 -1
- package/src/components/slideshow/Slideshow.stories.tsx +1 -0
- package/src/components/slideshow/Slideshow.test.tsx +2 -0
- package/src/components/slideshow/SlideshowControls.stories.tsx +2 -0
- package/src/components/slideshow/SlideshowItem.tsx +2 -0
- package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
- package/src/components/switch/Switch.test.tsx +7 -5
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/table/Table.test.tsx +2 -0
- package/src/components/table/Table.tsx +2 -0
- package/src/components/table/TableBody.test.tsx +2 -0
- package/src/components/table/TableBody.tsx +2 -0
- package/src/components/table/TableCell.test.tsx +3 -1
- package/src/components/table/TableCell.tsx +2 -0
- package/src/components/table/TableHeader.test.tsx +2 -0
- package/src/components/table/TableHeader.tsx +2 -0
- package/src/components/table/TableRow.test.tsx +2 -0
- package/src/components/table/TableRow.tsx +2 -0
- package/src/components/tabs/Tab.test.tsx +2 -0
- package/src/components/tabs/Tab.tsx +1 -1
- package/src/components/tabs/TabList.test.tsx +2 -0
- package/src/components/tabs/TabPanel.test.tsx +2 -0
- package/src/components/tabs/TabPanel.tsx +2 -0
- package/src/components/tabs/TabProvider.test.tsx +2 -0
- package/src/components/tabs/TabProvider.tsx +1 -1
- package/src/components/tabs/Tabs.stories.tsx +1 -1
- package/src/components/text/Text.stories.tsx +1 -1
- package/src/components/text/Text.test.tsx +2 -0
- package/src/components/text/Text.tsx +2 -0
- package/src/components/text-field/TextField.test.tsx +10 -9
- package/src/components/text-field/TextField.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +7 -29
- package/src/components/thumbnail/Thumbnail.tsx +11 -11
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +1 -2
- package/src/components/tooltip/Tooltip.test.tsx +8 -14
- package/src/components/uploader/Uploader.test.tsx +4 -2
- package/src/components/user-block/UserBlock.stories.tsx +2 -0
- package/src/components/user-block/UserBlock.test.tsx +3 -1
- package/src/hooks/useId.test.tsx +1 -0
- package/src/hooks/useInfiniteScroll.tsx +1 -1
- package/src/hooks/usePreviousValue.ts +1 -0
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +1 -0
- package/src/stories/decorators/withNestedProps.tsx +1 -0
- package/src/stories/decorators/withThemedBackground.tsx +2 -0
- package/src/stories/decorators/withWrapper.tsx +2 -0
- package/src/stories/utils/CustomLink.tsx +1 -0
- package/src/testing/utils/ThemeSentinel.tsx +1 -0
- package/src/untypped-modules.d.ts +0 -4
- package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
- package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
- package/src/utils/Portal/Portal.test.tsx +1 -0
- package/src/utils/Portal/PortalProvider.stories.jsx +1 -0
- package/src/utils/Portal/PortalProvider.test.tsx +2 -1
- package/src/utils/date/getYearDisplayName.test.ts +1 -1
- package/src/utils/disabled/DisabledStateProvider.stories.tsx +2 -0
- package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
- package/src/utils/react/OnBeforeUnmount.tsx +1 -1
- package/src/utils/react/renderButtonOrLink.tsx +16 -0
- package/src/utils/react/skipRender.tsx +2 -2
- package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
- package/src/utils/type/HasPolymorphicAs.ts +2 -0
- package/src/utils/type/index.ts +0 -1
- package/utils/index.d.ts +6 -6
- package/src/utils/react/RawClickable.test.tsx +0 -153
- package/src/utils/react/RawClickable.tsx +0 -65
- package/src/utils/type/HasRequiredLinkHref.ts +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { DatePickerProps } from '@lumx/react';
|
|
2
4
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
3
5
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -7,15 +9,15 @@ import { DatePicker } from '.';
|
|
|
7
9
|
import { CLASSNAME } from './constants';
|
|
8
10
|
|
|
9
11
|
const mockedDate = new Date(1487721600000);
|
|
10
|
-
Date.now =
|
|
11
|
-
|
|
12
|
+
Date.now = jest.fn(() => mockedDate.valueOf());
|
|
13
|
+
jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
12
14
|
getYearDisplayName: () => 'année',
|
|
13
15
|
}));
|
|
14
16
|
|
|
15
17
|
const setup = (propsOverride: Partial<DatePickerProps> = {}) => {
|
|
16
18
|
const props: DatePickerProps = {
|
|
17
19
|
locale: 'fr',
|
|
18
|
-
onChange:
|
|
20
|
+
onChange: jest.fn(),
|
|
19
21
|
value: mockedDate,
|
|
20
22
|
nextButtonProps: { label: 'Next month' },
|
|
21
23
|
previousButtonProps: { label: 'Previous month' },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
4
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
3
5
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
@@ -8,8 +10,8 @@ import { DatePickerControlled, DatePickerControlledProps } from './DatePickerCon
|
|
|
8
10
|
import { CLASSNAME } from './constants';
|
|
9
11
|
|
|
10
12
|
const mockedDate = new Date(1487721600000);
|
|
11
|
-
Date.now =
|
|
12
|
-
|
|
13
|
+
Date.now = jest.fn(() => mockedDate.valueOf());
|
|
14
|
+
jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
13
15
|
getYearDisplayName: () => 'année',
|
|
14
16
|
}));
|
|
15
17
|
|
|
@@ -18,14 +20,14 @@ type SetupProps = Partial<DatePickerControlledProps>;
|
|
|
18
20
|
const setup = (propsOverride: SetupProps = {}) => {
|
|
19
21
|
const props: DatePickerControlledProps = {
|
|
20
22
|
locale: 'fr',
|
|
21
|
-
onChange:
|
|
22
|
-
onNextMonthChange:
|
|
23
|
-
onPrevMonthChange:
|
|
23
|
+
onChange: jest.fn(),
|
|
24
|
+
onNextMonthChange: jest.fn(),
|
|
25
|
+
onPrevMonthChange: jest.fn(),
|
|
24
26
|
selectedMonth: mockedDate,
|
|
25
27
|
value: mockedDate,
|
|
26
28
|
nextButtonProps: { label: 'Next month' },
|
|
27
29
|
previousButtonProps: { label: 'Previous month' },
|
|
28
|
-
onMonthChange:
|
|
30
|
+
onMonthChange: jest.fn(),
|
|
29
31
|
...propsOverride,
|
|
30
32
|
};
|
|
31
33
|
render(<DatePickerControlled {...props} />);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
2
4
|
import { render, screen } from '@testing-library/react';
|
|
3
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -8,8 +10,8 @@ import { DatePickerField, DatePickerFieldProps } from './DatePickerField';
|
|
|
8
10
|
import { CLASSNAME } from './constants';
|
|
9
11
|
|
|
10
12
|
const mockedDate = new Date(1487721600000);
|
|
11
|
-
Date.now =
|
|
12
|
-
|
|
13
|
+
Date.now = jest.fn(() => mockedDate.valueOf());
|
|
14
|
+
jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
13
15
|
getYearDisplayName: () => 'année',
|
|
14
16
|
}));
|
|
15
17
|
|
|
@@ -17,7 +19,7 @@ const setup = (propsOverride: Partial<DatePickerFieldProps> = {}, { wrapper }: S
|
|
|
17
19
|
const props: DatePickerFieldProps = {
|
|
18
20
|
label: 'DatePickerField',
|
|
19
21
|
locale: 'fr',
|
|
20
|
-
onChange:
|
|
22
|
+
onChange: jest.fn(),
|
|
21
23
|
value: mockedDate,
|
|
22
24
|
nextButtonProps: { label: 'Next month' },
|
|
23
25
|
previousButtonProps: { label: 'Previous month' },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { Dialog, DialogProps } from '@lumx/react/components/dialog/Dialog';
|
|
2
4
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
3
5
|
import { render, screen } from '@testing-library/react';
|
|
@@ -49,7 +51,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
49
51
|
|
|
50
52
|
describe('Events', () => {
|
|
51
53
|
it('should trigger `onClose` when pressing `escape` key', async () => {
|
|
52
|
-
const onClose =
|
|
54
|
+
const onClose = jest.fn();
|
|
53
55
|
setup({ isOpen: true, onClose });
|
|
54
56
|
|
|
55
57
|
await userEvent.keyboard('[Escape]');
|
|
@@ -57,7 +59,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
it('should not trigger `onClose` when pressing any other key', async () => {
|
|
60
|
-
const onClose =
|
|
62
|
+
const onClose = jest.fn();
|
|
61
63
|
setup({ isOpen: true, onClose });
|
|
62
64
|
|
|
63
65
|
await userEvent.keyboard('a');
|
|
@@ -65,7 +67,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
it('should not trigger `onClose` when pressing `escape` key with `preventAutoClose` set to `true`', async () => {
|
|
68
|
-
const onClose =
|
|
70
|
+
const onClose = jest.fn();
|
|
69
71
|
setup({ isOpen: true, onClose, preventAutoClose: true });
|
|
70
72
|
|
|
71
73
|
await userEvent.keyboard('[Escape]');
|
|
@@ -73,7 +75,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
73
75
|
});
|
|
74
76
|
|
|
75
77
|
it('should not trigger `onClose` when pressing `escape` key with `preventCloseOnEscape` set to `true`', async () => {
|
|
76
|
-
const onClose =
|
|
78
|
+
const onClose = jest.fn();
|
|
77
79
|
setup({ isOpen: true, onClose, preventCloseOnEscape: true });
|
|
78
80
|
|
|
79
81
|
await userEvent.keyboard('[Escape]');
|
|
@@ -28,7 +28,7 @@ const setup = (propsOverride: Partial<DropdownProps> = {}) => {
|
|
|
28
28
|
describe(`<${Dropdown.displayName}>`, () => {
|
|
29
29
|
describe('Events', () => {
|
|
30
30
|
it('should trigger `onClose` when pressing `escape` key', async () => {
|
|
31
|
-
const onClose =
|
|
31
|
+
const onClose = jest.fn();
|
|
32
32
|
setup({
|
|
33
33
|
closeOnEscape: true,
|
|
34
34
|
onClose,
|
|
@@ -40,7 +40,7 @@ describe(`<${Dropdown.displayName}>`, () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('should not trigger `onClose` when pressing any other key', async () => {
|
|
43
|
-
const onClose =
|
|
43
|
+
const onClose = jest.fn();
|
|
44
44
|
setup({ isOpen: true, onClose, closeOnEscape: true });
|
|
45
45
|
|
|
46
46
|
await userEvent.keyboard('a');
|
|
@@ -48,7 +48,7 @@ describe(`<${Dropdown.displayName}>`, () => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('should not trigger `onClose` when pressing `escape` key with `closeOnEscape` set to `false`', async () => {
|
|
51
|
-
const onClose =
|
|
51
|
+
const onClose = jest.fn();
|
|
52
52
|
setup({ isOpen: true, onClose, closeOnEscape: false });
|
|
53
53
|
|
|
54
54
|
await userEvent.keyboard('[Escape]');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
3
4
|
import { queryByRole, render, screen } from '@testing-library/react';
|
|
4
5
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -10,7 +11,7 @@ import { ExpansionPanel, ExpansionPanelProps } from '.';
|
|
|
10
11
|
|
|
11
12
|
const CLASSNAME = ExpansionPanel.className as string;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
jest.mock('@lumx/react/utils/browser/isFocusVisible');
|
|
14
15
|
|
|
15
16
|
const mockChildrenContent = 'children content';
|
|
16
17
|
|
|
@@ -54,7 +55,7 @@ const setup = (
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
describe(`<${ExpansionPanel.displayName}>`, () => {
|
|
57
|
-
(isFocusVisible as Mock).mockReturnValue(false);
|
|
58
|
+
(isFocusVisible as jest.Mock).mockReturnValue(false);
|
|
58
59
|
|
|
59
60
|
describe('Render', () => {
|
|
60
61
|
it('should render default', () => {
|
|
@@ -99,9 +100,9 @@ describe(`<${ExpansionPanel.displayName}>`, () => {
|
|
|
99
100
|
});
|
|
100
101
|
|
|
101
102
|
describe('Events', () => {
|
|
102
|
-
const onOpen =
|
|
103
|
-
const onClose =
|
|
104
|
-
const onToggleOpen =
|
|
103
|
+
const onOpen = jest.fn();
|
|
104
|
+
const onClose = jest.fn();
|
|
105
|
+
const onToggleOpen = jest.fn();
|
|
105
106
|
|
|
106
107
|
beforeEach(onOpen.mockClear);
|
|
107
108
|
beforeEach(onClose.mockClear);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { headingElementArgType, HEADING_ELEMENTS } from '@lumx/react/stories/controls/element';
|
|
2
3
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
3
4
|
import { ALL_TYPOGRAPHY } from '@lumx/react/stories/controls/typography';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HeadingElement } from '@lumx/react/utils/type';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
3
|
import { MAX_HEADING_LEVEL } from './constants';
|
|
4
4
|
import { HeadingLevelContext } from './context';
|
|
5
5
|
import { useHeadingLevel } from './useHeadingLevel';
|
|
@@ -1,47 +1,21 @@
|
|
|
1
|
+
import DefaultStory, { SizeAndShape as DefaultSizeAndShape } from '@lumx/core/js/components/Icon/Stories';
|
|
1
2
|
import { mdiEmail } from '@lumx/icons';
|
|
2
|
-
import { ColorPalette, ColorVariant, GridColumn, Icon,
|
|
3
|
+
import { ColorPalette, ColorVariant, GridColumn, Icon, Size } from '@lumx/react';
|
|
3
4
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
4
5
|
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
5
|
-
import { iconArgType } from '@lumx/react/stories/controls/icons';
|
|
6
|
-
import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
|
|
7
6
|
import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
|
|
8
7
|
|
|
9
|
-
const iconSizes: Array<IconSizes> = [Size.xxs, Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl];
|
|
10
|
-
|
|
11
8
|
export default {
|
|
12
9
|
title: 'LumX components/icon/Icon',
|
|
13
10
|
component: Icon,
|
|
14
|
-
|
|
15
|
-
argTypes: {
|
|
16
|
-
icon: iconArgType,
|
|
17
|
-
hasShape: { control: 'boolean' },
|
|
18
|
-
color: colorArgType,
|
|
19
|
-
colorVariant: colorVariantArgType,
|
|
20
|
-
},
|
|
11
|
+
...DefaultStory,
|
|
21
12
|
};
|
|
22
13
|
|
|
23
14
|
/**
|
|
24
15
|
* All combinations of size and shape
|
|
25
16
|
*/
|
|
26
17
|
export const SizeAndShape = {
|
|
27
|
-
|
|
28
|
-
icon: mdiEmail,
|
|
29
|
-
},
|
|
30
|
-
argTypes: {
|
|
31
|
-
hasShape: { control: false },
|
|
32
|
-
size: { control: false },
|
|
33
|
-
},
|
|
34
|
-
decorators: [
|
|
35
|
-
withCombinations({
|
|
36
|
-
combinations: {
|
|
37
|
-
cols: { key: 'size', options: withUndefined(iconSizes) },
|
|
38
|
-
rows: {
|
|
39
|
-
Default: {},
|
|
40
|
-
'Has shape': { hasShape: true },
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
18
|
+
...DefaultSizeAndShape,
|
|
45
19
|
};
|
|
46
20
|
|
|
47
21
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
4
|
|
|
5
5
|
import { getByClassName, getByTagName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
|
+
import Tests from '@lumx/core/js/components/Icon/Tests';
|
|
7
8
|
import { Icon, IconProps } from './Icon';
|
|
8
9
|
|
|
9
10
|
const CLASSNAME = Icon.className as string;
|
|
@@ -27,89 +28,7 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
|
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
describe(`<${Icon.displayName}>`, () => {
|
|
30
|
-
|
|
31
|
-
it('should render default', () => {
|
|
32
|
-
const { i, svg, path, props } = setup();
|
|
33
|
-
|
|
34
|
-
expect(i).toBeInTheDocument();
|
|
35
|
-
expect(i).toHaveClass(CLASSNAME);
|
|
36
|
-
expect(i?.className).toMatchInlineSnapshot('"lumx-icon lumx-icon--no-shape lumx-icon--path"');
|
|
37
|
-
|
|
38
|
-
expect(svg).toBeInTheDocument();
|
|
39
|
-
expect(svg).toHaveAttribute('aria-hidden', 'true');
|
|
40
|
-
expect(svg).not.toHaveAttribute('role');
|
|
41
|
-
|
|
42
|
-
expect(path).toBeInTheDocument();
|
|
43
|
-
expect(path).toHaveAttribute('d', props.icon);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should adapt svg with alternate text', () => {
|
|
47
|
-
const { svg, props } = setup({ alt: 'Alternate text' });
|
|
48
|
-
expect(svg).toHaveAttribute('aria-label', props.alt);
|
|
49
|
-
expect(svg).not.toHaveAttribute('aria-hidden');
|
|
50
|
-
expect(svg).toHaveAttribute('role');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('size', () => {
|
|
54
|
-
it('should render size', () => {
|
|
55
|
-
const { i } = setup({ size: Size.s });
|
|
56
|
-
expect(i).toHaveClass('lumx-icon--size-s');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should adapt xxs size with hasShape', () => {
|
|
60
|
-
const { i } = setup({ hasShape: true, size: Size.xxs });
|
|
61
|
-
expect(i).toHaveClass('lumx-icon--size-s');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should adapt xs size with hasShape', () => {
|
|
65
|
-
const { i } = setup({ hasShape: true, size: Size.xs });
|
|
66
|
-
expect(i).toHaveClass('lumx-icon--size-s');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should adapt xxl size with hasShape', () => {
|
|
70
|
-
const { i } = setup({ hasShape: true, size: Size.xxl });
|
|
71
|
-
expect(i).toHaveClass('lumx-icon--size-xl');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should add default size with hasShape', () => {
|
|
75
|
-
const { i } = setup({ hasShape: true });
|
|
76
|
-
expect(i).toHaveClass('lumx-icon--size-m');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('color', () => {
|
|
81
|
-
it('should render color and color variant', () => {
|
|
82
|
-
const { i } = setup({
|
|
83
|
-
color: ColorPalette.primary,
|
|
84
|
-
colorVariant: ColorVariant.D1,
|
|
85
|
-
});
|
|
86
|
-
expect(i).toHaveClass('lumx-icon--color-primary lumx-icon--color-variant-D1');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should improve yellow icon color contrast with alert circle icon', () => {
|
|
90
|
-
const { i } = setup({
|
|
91
|
-
color: ColorPalette.yellow,
|
|
92
|
-
icon: mdiAlertCircle,
|
|
93
|
-
});
|
|
94
|
-
expect(i).toHaveClass('lumx-icon--color-yellow lumx-icon--has-dark-layer');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should set a default color on dark theme', () => {
|
|
98
|
-
const { i } = setup({ theme: Theme.dark });
|
|
99
|
-
expect(i).toHaveClass('lumx-icon--color-light lumx-icon--theme-dark');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should set a default color on has shape', () => {
|
|
103
|
-
const { i } = setup({ hasShape: true });
|
|
104
|
-
expect(i).toHaveClass('lumx-icon--color-dark lumx-icon--has-shape');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should set a default color variant on has shape & dark color', () => {
|
|
108
|
-
const { i } = setup({ color: ColorPalette.dark, hasShape: true });
|
|
109
|
-
expect(i).toHaveClass('lumx-icon--color-variant-L2 lumx-icon--color-dark lumx-icon--has-shape');
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
31
|
+
Tests((props: IconProps, { wrapper }: any) => render(<Icon {...props} />, { wrapper }));
|
|
113
32
|
|
|
114
33
|
// Common tests suite.
|
|
115
34
|
commonTestsSuiteRTL(setup, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
2
|
-
import { render, within, screen
|
|
4
|
+
import { render, within, screen } from '@testing-library/react';
|
|
3
5
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
4
6
|
import userEvent from '@testing-library/user-event';
|
|
5
7
|
import { useImageSize } from '@lumx/react/hooks/useImageSize';
|
|
@@ -16,8 +18,8 @@ import Meta, {
|
|
|
16
18
|
WithMosaicTrigger,
|
|
17
19
|
} from './ImageLightbox.stories';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
jest.mock('@lumx/react/hooks/useImageSize');
|
|
22
|
+
jest.mock('@lumx/react/hooks/useSizeOnWindowResize');
|
|
21
23
|
|
|
22
24
|
const CLASSNAME = ImageLightbox.className as string;
|
|
23
25
|
const baseProps = Meta.args;
|
|
@@ -54,7 +56,7 @@ const queries = {
|
|
|
54
56
|
describe(`<${ImageLightbox.displayName}>`, () => {
|
|
55
57
|
beforeEach(() => {
|
|
56
58
|
(useImageSize as any).mockReturnValue(null);
|
|
57
|
-
(useSizeOnWindowResize as any).mockReturnValue([null,
|
|
59
|
+
(useSizeOnWindowResize as any).mockReturnValue([null, jest.fn()]);
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
describe('render', () => {
|
|
@@ -157,9 +159,7 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
157
159
|
|
|
158
160
|
// Close on escape
|
|
159
161
|
await userEvent.keyboard('{escape}');
|
|
160
|
-
|
|
161
|
-
expect(imageLightbox).not.toBeInTheDocument();
|
|
162
|
-
});
|
|
162
|
+
expect(imageLightbox).not.toBeInTheDocument();
|
|
163
163
|
|
|
164
164
|
// Focus moved back to the trigger button
|
|
165
165
|
expect(buttonTrigger).toHaveFocus();
|
|
@@ -185,9 +185,7 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
185
185
|
|
|
186
186
|
// Close on escape
|
|
187
187
|
await userEvent.keyboard('{escape}');
|
|
188
|
-
|
|
189
|
-
expect(imageLightbox).not.toBeInTheDocument();
|
|
190
|
-
});
|
|
188
|
+
expect(imageLightbox).not.toBeInTheDocument();
|
|
191
189
|
|
|
192
190
|
// Focus moved back to the trigger button
|
|
193
191
|
expect(buttonTrigger).toHaveFocus();
|
|
@@ -198,7 +196,7 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
198
196
|
const scrollAreaSize = { width: 600, height: 600 };
|
|
199
197
|
beforeEach(() => {
|
|
200
198
|
(useImageSize as any).mockImplementation((_: any, getInitialSize: any) => getInitialSize?.() || null);
|
|
201
|
-
(useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize,
|
|
199
|
+
(useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize, jest.fn()]);
|
|
202
200
|
});
|
|
203
201
|
|
|
204
202
|
it('should use the image initial size', () => {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import type { IconButtonProps, LightboxProps, SlideshowProps, ThumbnailProps } from '@lumx/react';
|
|
2
4
|
import type { HasClassName } from '@lumx/react/utils/type';
|
|
3
5
|
import type { ImageCaptionMetadata } from '@lumx/react/components/image-block/ImageCaption';
|