@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
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@lumx/react';
|
|
11
11
|
import cloneDeep from 'lodash/cloneDeep';
|
|
12
12
|
import set from 'lodash/set';
|
|
13
|
-
import { useState } from 'react';
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
14
|
|
|
15
15
|
export default { title: 'LumX components/progress-tracker/Progress Tracker' };
|
|
16
16
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
2
4
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
3
5
|
import { render } from '@testing-library/react';
|
|
@@ -84,7 +86,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
describe('Events', () => {
|
|
87
|
-
const onChange =
|
|
89
|
+
const onChange = jest.fn();
|
|
88
90
|
|
|
89
91
|
it('should trigger `onChange` when radioButton is clicked', async () => {
|
|
90
92
|
const value = 'value';
|
|
@@ -100,7 +102,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
100
102
|
|
|
101
103
|
describe('Disabled state', () => {
|
|
102
104
|
it('should be disabled with isDisabled', async () => {
|
|
103
|
-
const onChange =
|
|
105
|
+
const onChange = jest.fn();
|
|
104
106
|
const { radioButton, input } = setup({ isDisabled: true, onChange });
|
|
105
107
|
|
|
106
108
|
expect(radioButton).toHaveClass('lumx-radio-button--is-disabled');
|
|
@@ -113,7 +115,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
113
115
|
});
|
|
114
116
|
|
|
115
117
|
it('should be disabled with aria-disabled', async () => {
|
|
116
|
-
const onChange =
|
|
118
|
+
const onChange = jest.fn();
|
|
117
119
|
const { radioButton, input } = setup({ 'aria-disabled': true, onChange });
|
|
118
120
|
|
|
119
121
|
expect(radioButton).toHaveClass('lumx-radio-button--is-disabled');
|
|
@@ -3,7 +3,7 @@ import { List, ListItem, Select, Size, TextField } from '@lumx/react';
|
|
|
3
3
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
4
4
|
import noop from 'lodash/noop';
|
|
5
5
|
import range from 'lodash/range';
|
|
6
|
-
import { SyntheticEvent, useState } from 'react';
|
|
6
|
+
import React, { SyntheticEvent, useState } from 'react';
|
|
7
7
|
import { SelectVariant } from './constants';
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import { Theme } from '@lumx/core/js/constants';
|
|
3
4
|
import { Chip } from '@lumx/react/components/chip/Chip';
|
|
4
5
|
import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
|
|
@@ -12,8 +13,8 @@ import { Select, SelectProps, SelectVariant } from './Select';
|
|
|
12
13
|
|
|
13
14
|
const CLASSNAME = Select.className as string;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
jest.mock('@lumx/react/utils/browser/isFocusVisible');
|
|
17
|
+
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -34,7 +35,7 @@ const setup = (propsOverride: Partial<SelectProps> = {}, { wrapper }: SetupRende
|
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
describe(`<${Select.displayName}>`, () => {
|
|
37
|
-
(isFocusVisible as Mock).mockReturnValue(false);
|
|
38
|
+
(isFocusVisible as jest.Mock).mockReturnValue(false);
|
|
38
39
|
|
|
39
40
|
describe('Props', () => {
|
|
40
41
|
it('should have default classNames', () => {
|
|
@@ -143,7 +144,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
143
144
|
|
|
144
145
|
describe('Events', () => {
|
|
145
146
|
it('should trigger `onDropdownClose` on escape', async () => {
|
|
146
|
-
const onDropdownClose =
|
|
147
|
+
const onDropdownClose = jest.fn();
|
|
147
148
|
const { getDropdown } = setup({ isOpen: true, onDropdownClose });
|
|
148
149
|
|
|
149
150
|
const dropdown = getDropdown();
|
|
@@ -155,7 +156,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
155
156
|
|
|
156
157
|
describe('should trigger `onInputClick` when the select button is clicked', () => {
|
|
157
158
|
it('with input variant', async () => {
|
|
158
|
-
const onClick =
|
|
159
|
+
const onClick = jest.fn();
|
|
159
160
|
const { inputWrapper } = setup({ onInputClick: onClick, variant: SelectVariant.input });
|
|
160
161
|
|
|
161
162
|
await userEvent.click(inputWrapper as any);
|
|
@@ -163,7 +164,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
163
164
|
});
|
|
164
165
|
|
|
165
166
|
it('with chip variant', async () => {
|
|
166
|
-
const onClick =
|
|
167
|
+
const onClick = jest.fn();
|
|
167
168
|
const { chip } = setup({ onInputClick: onClick, variant: SelectVariant.chip });
|
|
168
169
|
|
|
169
170
|
await userEvent.click(chip as any);
|
|
@@ -173,7 +174,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
173
174
|
|
|
174
175
|
it('should call onClear when clear icon is clicked in select input', async () => {
|
|
175
176
|
const value = 'Value';
|
|
176
|
-
const onClear =
|
|
177
|
+
const onClear = jest.fn();
|
|
177
178
|
const { select, props } = setup({ value, onClear, clearButtonProps: { label: 'Clear' } });
|
|
178
179
|
|
|
179
180
|
const clearButton = within(select).getByRole('button', { name: props.clearButtonProps?.label });
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from '@lumx/react';
|
|
15
15
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
16
16
|
import noop from 'lodash/noop';
|
|
17
|
-
import { MouseEventHandler, SyntheticEvent, useRef, useState } from 'react';
|
|
17
|
+
import React, { MouseEventHandler, SyntheticEvent, useRef, useState } from 'react';
|
|
18
18
|
import { SelectVariant } from './constants';
|
|
19
19
|
|
|
20
20
|
export default { title: 'LumX components/select/Select Multiple' };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { Theme } from '@lumx/core/js/constants';
|
|
2
4
|
import { Chip } from '@lumx/react/components/chip/Chip';
|
|
3
5
|
import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
|
|
@@ -16,7 +18,7 @@ import { SelectVariant } from './constants';
|
|
|
16
18
|
|
|
17
19
|
const CLASSNAME = SelectMultiple.className as string;
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -142,7 +144,7 @@ describe('<SelectMultiple>', () => {
|
|
|
142
144
|
describe('Events', () => {
|
|
143
145
|
describe('should trigger `onInputClick` when the select button is clicked', () => {
|
|
144
146
|
it('with input variant', async () => {
|
|
145
|
-
const onClick =
|
|
147
|
+
const onClick = jest.fn();
|
|
146
148
|
const { inputWrapper } = setup({ onInputClick: onClick, variant: SelectVariant.input });
|
|
147
149
|
|
|
148
150
|
await userEvent.click(inputWrapper as any);
|
|
@@ -150,7 +152,7 @@ describe('<SelectMultiple>', () => {
|
|
|
150
152
|
});
|
|
151
153
|
|
|
152
154
|
it('with chip variant', async () => {
|
|
153
|
-
const onClick =
|
|
155
|
+
const onClick = jest.fn();
|
|
154
156
|
const { chip } = setup({ onInputClick: onClick, variant: SelectVariant.chip });
|
|
155
157
|
|
|
156
158
|
await userEvent.click(chip as any);
|
|
@@ -159,7 +161,7 @@ describe('<SelectMultiple>', () => {
|
|
|
159
161
|
});
|
|
160
162
|
|
|
161
163
|
it('should call onClear when an item is clicked with the correct value', async () => {
|
|
162
|
-
const onClear =
|
|
164
|
+
const onClear = jest.fn();
|
|
163
165
|
const { valueChips } = setup({
|
|
164
166
|
onClear,
|
|
165
167
|
value: ['val 1', 'val 2'],
|
|
@@ -182,7 +184,7 @@ describe('<SelectMultiple>', () => {
|
|
|
182
184
|
const value1 = 'Value 1';
|
|
183
185
|
const value2 = 'Value 2';
|
|
184
186
|
|
|
185
|
-
const onClear =
|
|
187
|
+
const onClear = jest.fn();
|
|
186
188
|
const { chip } = setup({
|
|
187
189
|
onClear,
|
|
188
190
|
value: [value1, value2],
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { getAllByClassName, queryAllByClassName } from '@lumx/react/testing/utils/queries';
|
|
2
4
|
import { render, screen } from '@testing-library/react';
|
|
3
5
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
@@ -8,7 +10,7 @@ const CLASSNAME = SideNavigationItem.className as string;
|
|
|
8
10
|
|
|
9
11
|
const toggleButtonProps = { label: 'Toggle' };
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -104,7 +106,7 @@ describe(`<${SideNavigationItem.displayName}>`, () => {
|
|
|
104
106
|
|
|
105
107
|
describe('children and link', () => {
|
|
106
108
|
it('should render with children and link', () => {
|
|
107
|
-
const onActionClick =
|
|
109
|
+
const onActionClick = jest.fn();
|
|
108
110
|
const label = 'Side navigation item';
|
|
109
111
|
const { props, toggle, link } = setup({
|
|
110
112
|
label,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children, ReactNode } from 'react';
|
|
1
|
+
import React, { Children, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
@@ -7,9 +7,10 @@ import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
|
|
|
7
7
|
import { Emphasis, Icon, Size, IconButton, IconButtonProps } from '@lumx/react';
|
|
8
8
|
import { GenericProps, HasCloseMode, isComponent } from '@lumx/react/utils/type';
|
|
9
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
|
+
import { renderLink } from '@lumx/react/utils/react/renderLink';
|
|
11
|
+
import { renderButtonOrLink } from '@lumx/react/utils/react/renderButtonOrLink';
|
|
10
12
|
import { useId } from '@lumx/react/hooks/useId';
|
|
11
13
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
12
|
-
import { RawClickable } from '@lumx/react/utils/react/RawClickable';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Defines the props of the component.
|
|
@@ -112,15 +113,17 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
112
113
|
>
|
|
113
114
|
{shouldSplitActions ? (
|
|
114
115
|
<div className={`${CLASSNAME}__wrapper`}>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
{renderLink(
|
|
117
|
+
{
|
|
118
|
+
linkAs,
|
|
119
|
+
...linkProps,
|
|
120
|
+
className: `${CLASSNAME}__link`,
|
|
121
|
+
onClick,
|
|
122
|
+
tabIndex: 0,
|
|
123
|
+
},
|
|
124
|
+
icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />,
|
|
125
|
+
<span>{label}</span>,
|
|
126
|
+
)}
|
|
124
127
|
|
|
125
128
|
<IconButton
|
|
126
129
|
{...toggleButtonProps}
|
|
@@ -133,23 +136,25 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
133
136
|
/>
|
|
134
137
|
</div>
|
|
135
138
|
) : (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
renderButtonOrLink(
|
|
140
|
+
{
|
|
141
|
+
linkAs,
|
|
142
|
+
...linkProps,
|
|
143
|
+
className: `${CLASSNAME}__link`,
|
|
144
|
+
tabIndex: 0,
|
|
145
|
+
onClick,
|
|
146
|
+
...ariaProps,
|
|
147
|
+
},
|
|
148
|
+
icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />,
|
|
149
|
+
<span>{label}</span>,
|
|
150
|
+
hasContent && (
|
|
146
151
|
<Icon
|
|
147
152
|
className={`${CLASSNAME}__chevron`}
|
|
148
153
|
icon={isOpen ? mdiChevronUp : mdiChevronDown}
|
|
149
154
|
size={Size.xs}
|
|
150
155
|
/>
|
|
151
|
-
)
|
|
152
|
-
|
|
156
|
+
),
|
|
157
|
+
)
|
|
153
158
|
)}
|
|
154
159
|
|
|
155
160
|
{(closeMode === 'hide' || showChildren) && (
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
2
4
|
import { render } from '@testing-library/react';
|
|
3
5
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -5,7 +7,7 @@ import { Slider, SliderProps } from './Slider';
|
|
|
5
7
|
|
|
6
8
|
const CLASSNAME = Slider.className as string;
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
9
11
|
|
|
10
12
|
const setup = (props: Partial<SliderProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
13
|
render(<Slider {...(props as any)} />, { wrapper });
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
2
4
|
import { render } from '@testing-library/react';
|
|
3
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import userEvent from '@testing-library/user-event/';
|
|
5
7
|
|
|
6
8
|
import { Switch, SwitchProps } from './Switch';
|
|
7
9
|
|
|
@@ -22,7 +24,7 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
|
|
|
22
24
|
return { switchWrapper, input, helper, label, props };
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
26
28
|
|
|
27
29
|
describe(`<${Switch.displayName}>`, () => {
|
|
28
30
|
describe('Props', () => {
|
|
@@ -84,7 +86,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
describe('Events', () => {
|
|
87
|
-
const onChange =
|
|
89
|
+
const onChange = jest.fn();
|
|
88
90
|
|
|
89
91
|
it('should trigger `onChange` when switchWrapper is clicked', async () => {
|
|
90
92
|
const value = 'value';
|
|
@@ -100,7 +102,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
100
102
|
|
|
101
103
|
describe('Disabled state', () => {
|
|
102
104
|
it('should be disabled with isDisabled', async () => {
|
|
103
|
-
const onChange =
|
|
105
|
+
const onChange = jest.fn();
|
|
104
106
|
const { switchWrapper, input } = setup({ isDisabled: true, onChange });
|
|
105
107
|
|
|
106
108
|
expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
|
|
@@ -113,7 +115,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
113
115
|
});
|
|
114
116
|
|
|
115
117
|
it('should be disabled with aria-disabled', async () => {
|
|
116
|
-
const onChange =
|
|
118
|
+
const onChange = jest.fn();
|
|
117
119
|
const { switchWrapper, input } = setup({ 'aria-disabled': true, onChange });
|
|
118
120
|
|
|
119
121
|
expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
|