@laerdal/life-react-components 6.0.0-dev.20.full → 6.0.0-dev.5.full.full

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 (115) hide show
  1. package/dist/GlobalNavigationBar/Logo.cjs +1 -2
  2. package/dist/GlobalNavigationBar/Logo.cjs.map +1 -1
  3. package/dist/GlobalNavigationBar/Logo.js +1 -2
  4. package/dist/GlobalNavigationBar/Logo.js.map +1 -1
  5. package/dist/GlobalNavigationBar/desktop/MainMenu.cjs +1 -10
  6. package/dist/GlobalNavigationBar/desktop/MainMenu.cjs.map +1 -1
  7. package/dist/GlobalNavigationBar/desktop/MainMenu.js +1 -10
  8. package/dist/GlobalNavigationBar/desktop/MainMenu.js.map +1 -1
  9. package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs +2 -3
  10. package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs.map +1 -1
  11. package/dist/GlobalNavigationBar/desktop/RightSideNav.js +2 -3
  12. package/dist/GlobalNavigationBar/desktop/RightSideNav.js.map +1 -1
  13. package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs.map +1 -1
  14. package/dist/GlobalNavigationBar/mobile/CommonStyles.js.map +1 -1
  15. package/dist/HyperLink/HyperLink.cjs +2 -18
  16. package/dist/HyperLink/HyperLink.cjs.map +1 -1
  17. package/dist/HyperLink/HyperLink.d.ts +0 -2
  18. package/dist/HyperLink/HyperLink.js +2 -18
  19. package/dist/HyperLink/HyperLink.js.map +1 -1
  20. package/dist/InputFields/DatepickerField.cjs +1 -1
  21. package/dist/InputFields/DatepickerField.cjs.map +1 -1
  22. package/dist/InputFields/DatepickerField.d.ts +1 -1
  23. package/dist/InputFields/DatepickerField.js +1 -1
  24. package/dist/InputFields/DatepickerField.js.map +1 -1
  25. package/dist/MiniProductCard/MiniProductCard.cjs +1 -15
  26. package/dist/MiniProductCard/MiniProductCard.cjs.map +1 -1
  27. package/dist/MiniProductCard/MiniProductCard.d.ts +0 -1
  28. package/dist/MiniProductCard/MiniProductCard.js +1 -15
  29. package/dist/MiniProductCard/MiniProductCard.js.map +1 -1
  30. package/dist/NavItem/NavItem.cjs +1 -7
  31. package/dist/NavItem/NavItem.cjs.map +1 -1
  32. package/dist/NavItem/NavItem.js +1 -7
  33. package/dist/NavItem/NavItem.js.map +1 -1
  34. package/dist/Tabs/VerticalTabs.cjs +0 -1
  35. package/dist/Tabs/VerticalTabs.cjs.map +1 -1
  36. package/dist/Tabs/VerticalTabs.js +0 -1
  37. package/dist/Tabs/VerticalTabs.js.map +1 -1
  38. package/dist/styles/index.cjs +5 -5
  39. package/dist/styles/index.cjs.map +1 -1
  40. package/dist/styles/index.d.ts +2 -2
  41. package/dist/styles/index.js +2 -2
  42. package/dist/styles/index.js.map +1 -1
  43. package/package.json +147 -144
  44. package/dist/Accordion/__tests__/AccordionMenu.test.tsx +0 -42
  45. package/dist/Accordion/__tests__/ContentAccordion.test.tsx +0 -150
  46. package/dist/AuthPage/__tests__/AuthPage.test.tsx +0 -27
  47. package/dist/Banners/__tests__/Banner.test.tsx +0 -47
  48. package/dist/Banners/__tests__/OverviewBanner.test.tsx +0 -20
  49. package/dist/Breadcrumb/__tests__/Breadcrumb.test.tsx +0 -78
  50. package/dist/Button/__tests__/BackButton.test.tsx +0 -32
  51. package/dist/Button/__tests__/Button.test.tsx +0 -45
  52. package/dist/Button/__tests__/DualButton.test.tsx +0 -119
  53. package/dist/Card/HorizontalCard/__tests__/HorizontalCard.test.tsx +0 -71
  54. package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +0 -124
  55. package/dist/Card/__tests__/Card.test.tsx +0 -146
  56. package/dist/Chips/__tests__/ActionChip.test.tsx +0 -94
  57. package/dist/Chips/__tests__/ChoiceChips.test.tsx +0 -79
  58. package/dist/Chips/__tests__/FilterChip.test.tsx +0 -95
  59. package/dist/Chips/__tests__/InputChip.test.tsx +0 -155
  60. package/dist/ChipsInput/__tests__/ChipDropdownInput.test.tsx +0 -100
  61. package/dist/ChipsInput/__tests__/ChipInputFields.test.tsx +0 -155
  62. package/dist/Dropdown/__tests__/DropdownFilter.test.tsx +0 -39
  63. package/dist/Footer/__tests__/Footer.test.tsx +0 -182
  64. package/dist/GlobalNavigationBar/__tests__/GlobalNavigationBar.tests.d.ts +0 -1
  65. package/dist/GlobalNavigationBar/__tests__/Logo.test.tsx +0 -39
  66. package/dist/GlobalNavigationBar/__tests__/Logo.tests.d.ts +0 -1
  67. package/dist/GlobalNavigationBar/desktop/__tests__/DesktopActions.test.tsx +0 -108
  68. package/dist/GlobalNavigationBar/desktop/__tests__/ExtendedMainMenu.test.tsx +0 -28
  69. package/dist/GlobalNavigationBar/desktop/__tests__/MainMenu.test.tsx +0 -55
  70. package/dist/GlobalNavigationBar/desktop/__tests__/RightSideNav.test.tsx +0 -45
  71. package/dist/GlobalNavigationBar/desktop/__tests__/UserMenu.test.tsx +0 -125
  72. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenu.test.tsx +0 -317
  73. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuContent.test.tsx +0 -294
  74. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuHeader.test.tsx +0 -195
  75. package/dist/InputFields/__tests__/NumberField.test.tsx +0 -67
  76. package/dist/InputFields/__tests__/NumberInput.test.tsx +0 -68
  77. package/dist/InputFields/__tests__/QuickSearch.test.tsx +0 -42
  78. package/dist/LinearProgress/__tests__/LinearProgress.test.tsx +0 -25
  79. package/dist/List/__tests__/ListRow.test.tsx +0 -18
  80. package/dist/List/__tests__/ListRow.tests.d.ts +0 -1
  81. package/dist/LoadingPage/__tests__/GlobalLoadingPage.test.tsx +0 -23
  82. package/dist/Modals/__tests__/Modal.test.tsx +0 -169
  83. package/dist/Modals/__tests__/ModalContainer.test.tsx +0 -77
  84. package/dist/Modals/__tests__/ModalContent.test.tsx +0 -126
  85. package/dist/NavItem/__tests__/NavItem.test.ts +0 -6
  86. package/dist/NotificationDot/__tests__/NotificationDot.test.tsx +0 -33
  87. package/dist/Paginator/__tests__/Paginator.test.tsx +0 -39
  88. package/dist/Popover/__tests__/Popover.test.tsx +0 -64
  89. package/dist/ProfileButton/__tests__/ProfileButton.test.tsx +0 -31
  90. package/dist/QuizButton/__tests__/QuizButton.test.tsx +0 -53
  91. package/dist/SegmentControl/__tests__/SegmentControl.test.tsx +0 -145
  92. package/dist/SideMenu/__tests__/SideMenu.test.tsx +0 -99
  93. package/dist/Switcher/__tests__/SwitcherMenuItem.tsx +0 -14
  94. package/dist/Table/__tests__/Table.test.tsx +0 -499
  95. package/dist/Tabs/__tests__/HorizontalTabs.test.tsx +0 -95
  96. package/dist/Tabs/__tests__/TabLink.test.tsx +0 -40
  97. package/dist/Tabs/__tests__/TabLink.tests.d.ts +0 -1
  98. package/dist/Tabs/__tests__/Tablist.test.tsx +0 -37
  99. package/dist/Tabs/__tests__/Tablist.tests.d.ts +0 -2
  100. package/dist/Tag/__tests__/Tag.test.tsx +0 -86
  101. package/dist/Toasters/__tests__/Toast.test.tsx +0 -74
  102. package/dist/Toggles/__tests__/ToggleButton.test.tsx +0 -53
  103. package/dist/Toggles/__tests__/ToggleSwitch.test.tsx +0 -87
  104. package/dist/Tooltips/__tests__/TooltipWrapper.test.tsx +0 -16
  105. package/dist/common/Link.cjs +0 -45
  106. package/dist/common/Link.cjs.map +0 -1
  107. package/dist/common/Link.d.ts +0 -9
  108. package/dist/common/Link.js +0 -37
  109. package/dist/common/Link.js.map +0 -1
  110. package/dist/common/NavigationHelper.cjs +0 -30
  111. package/dist/common/NavigationHelper.cjs.map +0 -1
  112. package/dist/common/NavigationHelper.d.ts +0 -4
  113. package/dist/common/NavigationHelper.js +0 -23
  114. package/dist/common/NavigationHelper.js.map +0 -1
  115. package/dist/styles/react-datepicker.css +0 -766
@@ -1,108 +0,0 @@
1
- import * as React from 'react';
2
- import DesktopActions, {DesktopActionsRef} from '../DesktopActions';
3
- import {act, render} from '../../../test-utils';
4
- import {DesktopMenuButtonTypes} from '../../types';
5
- import {SystemIcons} from '../../../icons';
6
- import {IconButtonStyled} from '../../../Button/Iconbutton';
7
- import {ProfileButtonContainer} from '../../../ProfileButton/ProfileButton';
8
-
9
- describe('DesktopActions', () => {
10
- const profileSpy = jest.fn();
11
- const actionSpy = jest.fn();
12
- const switcherSpy = jest.fn();
13
- const showSubMenuSpy = jest.fn();
14
-
15
- const profile: DesktopMenuButtonTypes = {
16
- type: 'profile',
17
- action: profileSpy,
18
- };
19
-
20
- const action: DesktopMenuButtonTypes = {
21
- type: 'action',
22
- action: actionSpy,
23
- icon: <SystemIcons.Search/>,
24
- };
25
-
26
- const switcher: DesktopMenuButtonTypes = {
27
- type: 'switcher',
28
- action: switcherSpy,
29
- };
30
-
31
-
32
- it('should render profile button', () => {
33
- const wrapper = render(<DesktopActions buttons={[profile]} onShowUserMenu={showSubMenuSpy}/>)
34
-
35
- expect(wrapper.container.querySelectorAll(`${ProfileButtonContainer}`)).toHaveLength(1);
36
- });
37
-
38
- it('should render action button', () => {
39
- const wrapper = render(<DesktopActions buttons={[action]} onShowUserMenu={showSubMenuSpy}/>)
40
-
41
- expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(1);
42
- });
43
-
44
- it('should render switcher button', () => {
45
- const wrapper = render(<DesktopActions buttons={[switcher]} onShowUserMenu={showSubMenuSpy}/>)
46
-
47
- expect(wrapper.container.querySelectorAll(`#globalNavAppsButton`)).toHaveLength(1);
48
- });
49
-
50
- it('should call profile action on profile button click', () => {
51
- const wrapper = render(<DesktopActions buttons={[profile]} onShowUserMenu={showSubMenuSpy}/>)
52
-
53
- act(() => {
54
- wrapper.container.querySelector('button')!.click();
55
- });
56
-
57
- expect(profileSpy).toHaveBeenCalled();
58
- });
59
-
60
- it('should call on sub menu open when action is not specified on profile button click', () => {
61
- const wrapper = render(<DesktopActions buttons={[{...profile, action: undefined}]}
62
- onShowUserMenu={showSubMenuSpy}/>)
63
-
64
- act(() => {
65
- wrapper.container.querySelector('button')!.click();
66
- });
67
-
68
- expect(showSubMenuSpy).toHaveBeenCalled();
69
- });
70
-
71
- it('should call action on action button click', () => {
72
- const wrapper = render(<DesktopActions buttons={[action]} onShowUserMenu={showSubMenuSpy}/>)
73
-
74
- act(() => {
75
- wrapper.container.querySelector('button')!.click();
76
- });
77
-
78
- expect(actionSpy).toHaveBeenCalled();
79
- });
80
-
81
- it('should call switcher action on switcher button click', () => {
82
- const wrapper = render(<DesktopActions buttons={[switcher]} onShowUserMenu={showSubMenuSpy}/>)
83
-
84
- act(() => {
85
- wrapper.container.querySelector('button')!.click();
86
- });
87
-
88
- expect(switcherSpy).toHaveBeenCalled();
89
- });
90
-
91
-
92
- it('should not throw exceptions when buttons are removed', async () => {
93
- const actionsRef = React.createRef<DesktopActionsRef>();
94
-
95
- const wrapper = render(<DesktopActions ref={actionsRef}
96
- buttons={[switcher, profile, action]}
97
- onShowUserMenu={showSubMenuSpy}/>)
98
-
99
- wrapper.rerender(<DesktopActions ref={actionsRef}
100
- buttons={[]}
101
- onShowUserMenu={showSubMenuSpy}/>)
102
-
103
- expect(wrapper.container.querySelectorAll(`#globalNavAppsButton`)).toHaveLength(0);
104
- expect(wrapper.container.querySelectorAll(`${ProfileButtonContainer}`)).toHaveLength(0);
105
- expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(0);
106
- });
107
-
108
- });
@@ -1,28 +0,0 @@
1
- import * as React from 'react';
2
- import {MenuNavigationItemTypeItem} from '../../types';
3
- import {render} from '../../../test-utils';
4
- import ExtendedMainMenu from '../ExtendedMainMenu';
5
- import { NavigationProvider } from '../../../Navigation';
6
-
7
- describe('ExtendedMainMenu', () => {
8
- const menuClickSpy = jest.fn();
9
- const items = [{
10
- label: 'item1',
11
- to: '#1'
12
- },
13
- {
14
- label: 'item2',
15
- to: '#2'
16
- }] as MenuNavigationItemTypeItem[];
17
-
18
- it('should render items', () => {
19
-
20
- const wrapper = render(
21
- <NavigationProvider currentPath='' isActiveRoute={() => false} navigate={(path: string, isExternal: boolean) => {}}>
22
- <ExtendedMainMenu clickMenuAction={menuClickSpy} navigationOptions={items}/>
23
- </NavigationProvider>);
24
-
25
- expect(wrapper.getByText('item1')).toBeDefined();
26
- expect(wrapper.getByText('item2')).toBeDefined();
27
- });
28
- });
@@ -1,55 +0,0 @@
1
- import * as React from 'react';
2
- import {MenuNavigationItemTypeItem} from '../../types';
3
- import {fireEvent, render} from '../../../test-utils';
4
- import {IconButtonStyled} from '../../../Button/Iconbutton';
5
- import MainMenu from '../MainMenu';
6
- import { act } from "react";
7
- import { NavigationProvider } from '../../../Navigation';
8
-
9
-
10
- describe('MainMenu', () => {
11
- const menuClickSpy = jest.fn();
12
- const navProps = {
13
- currentPath: '',
14
- isActiveRoute: () => false,
15
- navigate: (path: string, isExternal: boolean) => {}
16
- };
17
-
18
- const items = [{
19
- label: 'item1',
20
- to: '#1'
21
- },
22
- {
23
- label: 'item2',
24
- to: '#2'
25
- }] as MenuNavigationItemTypeItem[];
26
-
27
- it('should render items', () => {
28
- const wrapper = render(<NavigationProvider {...navProps}><MainMenu rightSideRef={{current: {offsetLeft: 10000}} as any} items={items}/></NavigationProvider>);
29
-
30
- expect(wrapper.getByText('item1')).toBeDefined();
31
- expect(wrapper.getByText('item2')).toBeDefined();
32
- });
33
-
34
- it('should not show extended menu if width is enough', () => {
35
- const wrapper = render(
36
- <NavigationProvider {...navProps}>
37
- <MainMenu items={items} rightSideRef={{current: {offsetLeft: 10000}} as any}/>
38
- </NavigationProvider>
39
- );
40
-
41
- act(() => {
42
- global.dispatchEvent(new Event('resize'));
43
- })
44
-
45
- expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(0);
46
- });
47
-
48
- it('should show extended menu if width is not enough', () => {
49
- const wrapper = render(<NavigationProvider {...navProps}><MainMenu rightSideRef={{current: {offsetLeft: 0}} as any}
50
- items={items}/></NavigationProvider>);
51
-
52
- expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(1);
53
- });
54
-
55
- });
@@ -1,45 +0,0 @@
1
- import * as React from 'react';
2
- import {MenuNavigationItemTypeItem} from '../../types';
3
- import {render} from '../../../test-utils';
4
- import ExtendedMainMenu from '../ExtendedMainMenu';
5
- import {IconButtonStyled} from '../../../Button/Iconbutton';
6
- import MainMenu from '../MainMenu';
7
- import RightSideNav from '../RightSideNav';
8
- import { NavigationProvider } from '../../../Navigation';
9
-
10
- describe('RightSideNav', () => {
11
-
12
- const navProps = {
13
- currentPath: '',
14
- isActiveRoute: () => false,
15
- navigate: (path: string, isExternal: boolean) => {}
16
- };
17
-
18
-
19
- const items = [{
20
- label: 'item1',
21
- to: '#1'
22
- },
23
- {
24
- label: 'item2',
25
- to: '#2'
26
- }] as MenuNavigationItemTypeItem[];
27
-
28
- it('should render items', () => {
29
- const wrapper = render(<NavigationProvider {...navProps}><RightSideNav items={items}/></NavigationProvider>);
30
-
31
- expect(wrapper.getByText('item1')).toBeDefined();
32
- expect(wrapper.getByText('item2')).toBeDefined();
33
- });
34
-
35
- it('should render action', () => {
36
- const wrapper = render(
37
- <NavigationProvider {...navProps}>
38
- <RightSideNav items={[]}
39
- action={{label: 'label', action: jest.fn()}}/>
40
- </NavigationProvider>);
41
-
42
- expect(wrapper.getByText('label')).toBeDefined();
43
- });
44
-
45
- });
@@ -1,125 +0,0 @@
1
- import * as React from 'react';
2
- import UserMenu from '../UserMenu';
3
- import {act, fireEvent, render} from '../../../test-utils';
4
- import {ProfileMenu} from '../../types';
5
- import {ProfileButtonContainer} from '../../../ProfileButton/ProfileButton';
6
- import { NavigationProvider } from '../../../Navigation/NavigationProvider';
7
-
8
-
9
-
10
- describe('UserMenu', () => {
11
-
12
- const navProps = {
13
- currentPath: '',
14
- isActiveRoute: () => false,
15
- navigate: (path: string, isExternal: boolean) => {}
16
- };
17
-
18
- it('should render profile icon', function () {
19
- const props: ProfileMenu = {
20
- user: {
21
- firstName: 'John',
22
- lastName: 'Doe',
23
- email: 'email'
24
- },
25
- sections: []
26
- }
27
- const wrapper = render(<NavigationProvider {...navProps}><UserMenu {...props} onHideUserMenu={jest.fn()}/></NavigationProvider>);
28
-
29
- expect(wrapper.container.querySelectorAll(`${ProfileButtonContainer}`)).toHaveLength(1);
30
-
31
- wrapper.unmount();
32
- });
33
-
34
- it('should render label', function () {
35
- const props: ProfileMenu = {
36
- user: {
37
- firstName: 'John',
38
- lastName: 'Doe',
39
- email: 'email'
40
- },
41
- sections: [],
42
- label: 'label'
43
- }
44
- const wrapper = render(<NavigationProvider {...navProps}><UserMenu {...props} onHideUserMenu={jest.fn()}/></NavigationProvider>);
45
-
46
- expect(wrapper.findByText('label')).toBeDefined();
47
-
48
- wrapper.unmount();
49
- });
50
-
51
- it('should render sign out button', function () {
52
- const props: ProfileMenu = {
53
- user: {
54
- firstName: 'John',
55
- lastName: 'Doe',
56
- email: 'email'
57
- },
58
- sections: [],
59
- signOut: {
60
- action: jest.fn(),
61
- label: 'sign out'
62
- }
63
- }
64
- const wrapper = render(<NavigationProvider {...navProps}><UserMenu {...props} onHideUserMenu={jest.fn()}/></NavigationProvider>);
65
-
66
- expect(wrapper.findByText('sign out')).toBeDefined();
67
-
68
- wrapper.unmount();
69
- });
70
-
71
- it('should render sections', function () {
72
- const props: ProfileMenu = {
73
- user: {
74
- firstName: 'John',
75
- lastName: 'Doe',
76
- email: 'email'
77
- },
78
- sections: [{
79
- label: 'label',
80
- items: [{
81
- label: 'item1',
82
- to: '#'
83
- }]
84
- }],
85
- }
86
- const wrapper = render(<NavigationProvider {...navProps}>
87
- <UserMenu {...props} onHideUserMenu={jest.fn()}/>
88
- </NavigationProvider>);
89
-
90
- expect(wrapper.getByText('item1')).toBeDefined();
91
- expect(wrapper.getByText('label')).toBeDefined();
92
-
93
- wrapper.unmount();
94
- });
95
-
96
- it('should close when item is clicked', async function () {
97
- const props: ProfileMenu = {
98
- user: {
99
- firstName: 'John',
100
- lastName: 'Doe',
101
- email: 'email'
102
- },
103
- sections: [{
104
- label: 'label',
105
- items: [{
106
- label: 'item1',
107
- to: 'http://localhost',
108
- external: true
109
- }]
110
- }],
111
- };
112
-
113
- const onClose = jest.fn();
114
- const wrapper = render(<NavigationProvider {...navProps}> <UserMenu {...props} onHideUserMenu={onClose}/> </NavigationProvider>);
115
-
116
- act(() => {
117
- fireEvent.click(wrapper.getByText('item1'));
118
- })
119
-
120
- expect(onClose).toHaveBeenCalled();
121
-
122
- wrapper.unmount();
123
- });
124
-
125
- });
@@ -1,317 +0,0 @@
1
- import * as React from 'react';
2
- import {act, render, waitFor} from '../../../test-utils';
3
- import {
4
- DesktopMenuButtonTypes,
5
- MenuNavigationItemTypeGroup,
6
- MenuNavigationItemTypeItem,
7
- MobileMenuButtonTypes
8
- } from '../../types';
9
- import {SystemIcons} from '../../../icons';
10
- import MobileMenu from '../MobileMenu';
11
- import { NavigationProvider } from '../../../Navigation';
12
-
13
- const navigateSpy = jest.fn();
14
- const isActiveRouteSpy = jest.fn();
15
-
16
- jest.mock('rooks', () => ({
17
- useDimensionsRef: () => [],
18
- useMediaMatch: () => true
19
-
20
- }));
21
-
22
-
23
-
24
- describe('MobileMenu', () => {
25
-
26
-
27
- const navProps = {
28
- currentPath: '',
29
- isActiveRoute: () => false,
30
- navigate: (path: string, isExternal: boolean) => {}
31
- };
32
-
33
-
34
- const mainNavigationOptions = [
35
- {
36
- label: 'Overview',
37
- to: '/',
38
- exact: true,
39
- onClick: () => {
40
- console.log('Clicked on overview page');
41
- },
42
- },
43
- {
44
- label: 'Services',
45
- to: '/services',
46
- },
47
- {
48
- label: 'Products',
49
- to: '/products',
50
- },
51
- ];
52
-
53
- const secondaryNavigationOptions = [
54
- {
55
- label: 'Pinned Tab',
56
- to: 'pinned',
57
- pinned: true
58
- },
59
- ];
60
-
61
- const headerActions: DesktopMenuButtonTypes[] = [
62
- {
63
- type: 'action',
64
- action: (e) => {
65
- console.log('search');
66
- },
67
- icon: <SystemIcons.Search/>,
68
- },
69
- {
70
- type: 'action',
71
- action: (e) => {
72
- console.log('notifications');
73
- },
74
- icon: <SystemIcons.Notification/>,
75
- },
76
- {
77
- type: 'action',
78
- action: (e) => {
79
- console.log('language');
80
- },
81
- icon: <SystemIcons.Language/>,
82
- },
83
- {
84
- type: 'action',
85
- action: (e) => {
86
- console.log('settings');
87
- },
88
- icon: <SystemIcons.GearSettings/>,
89
- },
90
- {
91
- type: 'profile',
92
- },
93
- {
94
- type: 'action',
95
- action: (e) => {
96
- console.log('shop');
97
- },
98
- icon: <SystemIcons.ShoppingCart/>,
99
- },
100
- {
101
- type: 'switcher',
102
- action: (e) => {
103
- // @ts-ignore
104
- window.portalNav.toggle();
105
- console.log('switcher')
106
- },
107
- }
108
- ];
109
-
110
- const notifications: MenuNavigationItemTypeItem[] = [
111
- {
112
- label: 'First',
113
- note: 'This is a note',
114
- to: '/n7',
115
- },
116
- {
117
- label: 'Second',
118
- note: 'This is a note',
119
- to: '/n6',
120
- },
121
- {
122
- label: 'Third',
123
- note: 'This is a note',
124
- to: '/n5',
125
- },
126
- {
127
- label: 'Fourth',
128
- note: 'This is a note',
129
- to: '/n4',
130
- },
131
- {
132
- label: 'Fifth',
133
- note: 'This is a note',
134
- to: '/n3',
135
- },
136
- {
137
- label: 'Sixth',
138
- note: 'This is a note',
139
- to: '/n2',
140
- },
141
- {
142
- label: 'Seventh',
143
- note: 'This is a note',
144
- to: '/n1',
145
- },
146
- ];
147
-
148
- const mobileActions: MobileMenuButtonTypes[] = [
149
- {
150
- type: 'submenu',
151
- menu: {
152
- type: 'custom',
153
- label: 'Search',
154
- custom: () => 'custom'
155
- },
156
- icon: <SystemIcons.Search/>,
157
- },
158
- {
159
- type: 'submenu',
160
- menu: {
161
- type: 'group',
162
- label: 'Notifications',
163
- items: notifications
164
- },
165
- icon: <SystemIcons.Notification/>,
166
- },
167
- {
168
- type: 'action',
169
- action: (e) => {
170
- console.log('language');
171
- return true;
172
- },
173
- icon: <SystemIcons.Language/>,
174
- },
175
- {
176
- type: 'profile',
177
- placement: 'left'
178
- },
179
- {
180
- type: 'switcher',
181
- action: (e) => {
182
- // @ts-ignore
183
- window.portalNav.toggle();
184
- console.log('switcher')
185
- },
186
- }
187
- ];
188
-
189
- const mobileStickyNav = [
190
- {
191
- label: 'Help',
192
- to: '/help',
193
- pinned: true,
194
- icon: <SystemIcons.Help/>,
195
- },
196
- {
197
- label: 'Support',
198
- to: '/support',
199
- pinned: true,
200
- icon: <SystemIcons.Support/>,
201
- },
202
- ];
203
-
204
- const accountSection = [
205
- {label: 'My Account', to: '/account/myaccount', icon: <SystemIcons.User/>, external: false},
206
- {label: 'Language & Region', to: '/account/language', icon: <SystemIcons.Language/>, external: false},
207
- {label: 'Settings', to: '/account/settings', icon: <SystemIcons.GearSettings/>, external: false},
208
- ];
209
-
210
- const organizationSection = [
211
- {
212
- label: 'Organization details',
213
- to: '/organization/myorganization',
214
- icon: <SystemIcons.Institute/>,
215
- external: false
216
- },
217
- {label: 'People', to: '/organization/user-management', icon: <SystemIcons.Team/>, external: false},
218
- ];
219
-
220
- const supportSection = [
221
- {
222
- label: 'Help',
223
- to: 'https://laerdal.force.com/HelpCenter',
224
- icon: <SystemIcons.Help/>,
225
- external: true,
226
- pinned: true
227
- },
228
- {
229
- label: 'Support',
230
- to: 'https://www.laerdal.com/support/',
231
- icon: <SystemIcons.Support/>,
232
- external: true,
233
- pinned: true
234
- },
235
- ];
236
-
237
- const mobileNavigationSubGroup = {
238
- type: 'group',
239
- items: [...organizationSection, ...supportSection],
240
- note: 'This is a note',
241
- header: {
242
- header: 'Title',
243
- note: 'Note Text'
244
- },
245
- footer: {
246
- header: 'Title',
247
- note: 'Note text',
248
- link: {
249
- label: 'Link text',
250
- href: '#',
251
- external: false
252
- }
253
- },
254
- action: {
255
- label: 'Sign out',
256
- action: () => {
257
- console.log('Sign out');
258
- },
259
- icon: <SystemIcons.Logout/>
260
- },
261
- label: 'Organization',
262
- icon: <SystemIcons.Institute/>,
263
- } as MenuNavigationItemTypeGroup;
264
-
265
- it('should render label', () => {
266
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu show={true} label={'label'} onClose={jest.fn()}/></NavigationProvider>)
267
-
268
- expect(wrapper.findByText('label')).toBeDefined();
269
- });
270
-
271
- it('should render header', () => {
272
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu show={true} header={{header: 'header', note: 'note'}} onClose={jest.fn()}/></NavigationProvider>)
273
-
274
- expect(wrapper.findByText('header')).toBeDefined();
275
- expect(wrapper.findByText('note')).toBeDefined();
276
- });
277
-
278
- it('should render footer', () => {
279
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu
280
- onClose={jest.fn()}
281
- show={true}
282
- footer={{header: 'header', note: 'note', link: {label: 'link', href: '#'}}}/></NavigationProvider>)
283
-
284
- expect(wrapper.findByText('header')).toBeDefined();
285
- expect(wrapper.findByText('note')).toBeDefined();
286
- expect(wrapper.findByText('link')).toBeDefined();
287
- });
288
-
289
- it('should render action', () => {
290
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu
291
- onClose={jest.fn()}
292
- show={true}
293
- action={{action: jest.fn(), label: 'action'}}/></NavigationProvider>)
294
-
295
- expect(wrapper.findByText('action')).toBeDefined();
296
- });
297
-
298
- it('should render items', () => {
299
- const items = [mobileNavigationSubGroup, ...mainNavigationOptions, ...mobileStickyNav]
300
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu show={true} onClose={jest.fn()} items={items}/></NavigationProvider>)
301
-
302
- items.forEach(item => {
303
- expect(wrapper.findByText(item.label)).toBeDefined();
304
- });
305
- });
306
-
307
- it('should call on close when close button is clicked', () => {
308
- const close = jest.fn();
309
- const wrapper = render(<NavigationProvider {...navProps}><MobileMenu show={true} label={'label'} onClose={close}/></NavigationProvider>)
310
-
311
- act(() => {
312
- wrapper.container.querySelector('button')!.click();
313
- });
314
- expect(close).toHaveBeenCalled();
315
- });
316
-
317
- });