@laerdal/life-react-components 6.0.0-dev.20.full → 6.0.0-dev.5.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.
- package/dist/Button/Button.cjs +5 -0
- package/dist/Button/Button.cjs.map +1 -1
- package/dist/Button/Button.js +5 -0
- package/dist/Button/Button.js.map +1 -1
- package/dist/GlobalNavigationBar/Logo.cjs +1 -2
- package/dist/GlobalNavigationBar/Logo.cjs.map +1 -1
- package/dist/GlobalNavigationBar/Logo.js +1 -2
- package/dist/GlobalNavigationBar/Logo.js.map +1 -1
- package/dist/GlobalNavigationBar/desktop/MainMenu.cjs +1 -10
- package/dist/GlobalNavigationBar/desktop/MainMenu.cjs.map +1 -1
- package/dist/GlobalNavigationBar/desktop/MainMenu.js +1 -10
- package/dist/GlobalNavigationBar/desktop/MainMenu.js.map +1 -1
- package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs +2 -3
- package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs.map +1 -1
- package/dist/GlobalNavigationBar/desktop/RightSideNav.js +2 -3
- package/dist/GlobalNavigationBar/desktop/RightSideNav.js.map +1 -1
- package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs.map +1 -1
- package/dist/GlobalNavigationBar/mobile/CommonStyles.js.map +1 -1
- package/dist/HyperLink/HyperLink.cjs +2 -18
- package/dist/HyperLink/HyperLink.cjs.map +1 -1
- package/dist/HyperLink/HyperLink.d.ts +0 -2
- package/dist/HyperLink/HyperLink.js +2 -18
- package/dist/HyperLink/HyperLink.js.map +1 -1
- package/dist/InputFields/DatepickerField.cjs +1 -1
- package/dist/InputFields/DatepickerField.cjs.map +1 -1
- package/dist/InputFields/DatepickerField.d.ts +1 -1
- package/dist/InputFields/DatepickerField.js +1 -1
- package/dist/InputFields/DatepickerField.js.map +1 -1
- package/dist/InputFields/TextField.cjs +1 -1
- package/dist/InputFields/TextField.cjs.map +1 -1
- package/dist/InputFields/TextField.js +1 -1
- package/dist/InputFields/TextField.js.map +1 -1
- package/dist/MiniProductCard/MiniProductCard.cjs +1 -15
- package/dist/MiniProductCard/MiniProductCard.cjs.map +1 -1
- package/dist/MiniProductCard/MiniProductCard.d.ts +0 -1
- package/dist/MiniProductCard/MiniProductCard.js +1 -15
- package/dist/MiniProductCard/MiniProductCard.js.map +1 -1
- package/dist/NavItem/NavItem.cjs +1 -7
- package/dist/NavItem/NavItem.cjs.map +1 -1
- package/dist/NavItem/NavItem.js +1 -7
- package/dist/NavItem/NavItem.js.map +1 -1
- package/dist/Tabs/VerticalTabs.cjs +0 -1
- package/dist/Tabs/VerticalTabs.cjs.map +1 -1
- package/dist/Tabs/VerticalTabs.js +0 -1
- package/dist/Tabs/VerticalTabs.js.map +1 -1
- package/dist/styles/colors.cjs +1 -0
- package/dist/styles/colors.cjs.map +1 -1
- package/dist/styles/colors.js +1 -0
- package/dist/styles/colors.js.map +1 -1
- package/dist/styles/index.cjs +5 -5
- package/dist/styles/index.cjs.map +1 -1
- package/dist/styles/index.d.ts +2 -2
- package/dist/styles/index.js +2 -2
- package/dist/styles/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/Accordion/__tests__/AccordionMenu.test.tsx +0 -42
- package/dist/Accordion/__tests__/ContentAccordion.test.tsx +0 -150
- package/dist/AuthPage/__tests__/AuthPage.test.tsx +0 -27
- package/dist/Banners/__tests__/Banner.test.tsx +0 -47
- package/dist/Banners/__tests__/OverviewBanner.test.tsx +0 -20
- package/dist/Breadcrumb/__tests__/Breadcrumb.test.tsx +0 -78
- package/dist/Button/__tests__/BackButton.test.tsx +0 -32
- package/dist/Button/__tests__/Button.test.tsx +0 -45
- package/dist/Button/__tests__/DualButton.test.tsx +0 -119
- package/dist/Card/HorizontalCard/__tests__/HorizontalCard.test.tsx +0 -71
- package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +0 -124
- package/dist/Card/__tests__/Card.test.tsx +0 -146
- package/dist/Chips/__tests__/ActionChip.test.tsx +0 -94
- package/dist/Chips/__tests__/ChoiceChips.test.tsx +0 -79
- package/dist/Chips/__tests__/FilterChip.test.tsx +0 -95
- package/dist/Chips/__tests__/InputChip.test.tsx +0 -155
- package/dist/ChipsInput/__tests__/ChipDropdownInput.test.tsx +0 -100
- package/dist/ChipsInput/__tests__/ChipInputFields.test.tsx +0 -155
- package/dist/Dropdown/__tests__/DropdownFilter.test.tsx +0 -39
- package/dist/Footer/__tests__/Footer.test.tsx +0 -182
- package/dist/GlobalNavigationBar/__tests__/Logo.test.tsx +0 -39
- package/dist/GlobalNavigationBar/desktop/__tests__/DesktopActions.test.tsx +0 -108
- package/dist/GlobalNavigationBar/desktop/__tests__/ExtendedMainMenu.test.tsx +0 -28
- package/dist/GlobalNavigationBar/desktop/__tests__/MainMenu.test.tsx +0 -55
- package/dist/GlobalNavigationBar/desktop/__tests__/RightSideNav.test.tsx +0 -45
- package/dist/GlobalNavigationBar/desktop/__tests__/UserMenu.test.tsx +0 -125
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenu.test.tsx +0 -317
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuContent.test.tsx +0 -294
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuHeader.test.tsx +0 -195
- package/dist/InputFields/__tests__/NumberField.test.tsx +0 -67
- package/dist/InputFields/__tests__/NumberInput.test.tsx +0 -68
- package/dist/InputFields/__tests__/QuickSearch.test.tsx +0 -42
- package/dist/LinearProgress/__tests__/LinearProgress.test.tsx +0 -25
- package/dist/List/__tests__/ListRow.test.tsx +0 -18
- package/dist/LoadingPage/__tests__/GlobalLoadingPage.test.tsx +0 -23
- package/dist/Modals/__tests__/Modal.test.tsx +0 -169
- package/dist/Modals/__tests__/ModalContainer.test.tsx +0 -77
- package/dist/Modals/__tests__/ModalContent.test.tsx +0 -126
- package/dist/NavItem/__tests__/NavItem.test.ts +0 -6
- package/dist/NotificationDot/__tests__/NotificationDot.test.tsx +0 -33
- package/dist/Paginator/__tests__/Paginator.test.tsx +0 -39
- package/dist/Popover/__tests__/Popover.test.tsx +0 -64
- package/dist/ProfileButton/__tests__/ProfileButton.test.tsx +0 -31
- package/dist/QuizButton/__tests__/QuizButton.test.tsx +0 -53
- package/dist/SegmentControl/__tests__/SegmentControl.test.tsx +0 -145
- package/dist/SideMenu/__tests__/SideMenu.test.tsx +0 -99
- package/dist/Switcher/__tests__/SwitcherMenuItem.tsx +0 -14
- package/dist/Table/__tests__/Table.test.tsx +0 -499
- package/dist/Tabs/__tests__/HorizontalTabs.test.tsx +0 -95
- package/dist/Tabs/__tests__/TabLink.test.tsx +0 -40
- package/dist/Tabs/__tests__/Tablist.test.tsx +0 -37
- package/dist/Tag/__tests__/Tag.test.tsx +0 -86
- package/dist/Toasters/__tests__/Toast.test.tsx +0 -74
- package/dist/Toggles/__tests__/ToggleButton.test.tsx +0 -53
- package/dist/Toggles/__tests__/ToggleSwitch.test.tsx +0 -87
- package/dist/Tooltips/__tests__/TooltipWrapper.test.tsx +0 -16
- package/dist/styles/react-datepicker.css +0 -766
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {render} from '../../../test-utils';
|
|
3
|
-
import MobileMenuContent from '../MobileMenuContent';
|
|
4
|
-
import {
|
|
5
|
-
DesktopMenuButtonTypes,
|
|
6
|
-
MenuNavigationItemTypeGroup,
|
|
7
|
-
MenuNavigationItemTypeItem,
|
|
8
|
-
MobileMenuButtonTypes
|
|
9
|
-
} from '../../types';
|
|
10
|
-
import {SystemIcons} from '../../../icons';
|
|
11
|
-
import { NavigationProvider } from '../../../Navigation';
|
|
12
|
-
|
|
13
|
-
const navigateSpy = jest.fn();
|
|
14
|
-
const isActiveRouteSpy = jest.fn();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
jest.mock('rooks', () => ({
|
|
18
|
-
useDimensionsRef: () => [],
|
|
19
|
-
useMediaMatch: () => true
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
describe('MobileMenuContent', () => {
|
|
23
|
-
|
|
24
|
-
const navProps = {
|
|
25
|
-
currentPath: '',
|
|
26
|
-
isActiveRoute: () => false,
|
|
27
|
-
navigate: (path: string, isExternal: boolean) => {}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const mainNavigationOptions = [
|
|
31
|
-
{
|
|
32
|
-
label: 'Overview',
|
|
33
|
-
to: '/',
|
|
34
|
-
exact: true,
|
|
35
|
-
onClick: () => {
|
|
36
|
-
console.log('Clicked on overview page');
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
label: 'Services',
|
|
41
|
-
to: '/services',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: 'Products',
|
|
45
|
-
to: '/products',
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
const secondaryNavigationOptions = [
|
|
50
|
-
{
|
|
51
|
-
label: 'Pinned Tab',
|
|
52
|
-
to: 'pinned',
|
|
53
|
-
pinned: true
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const headerActions: DesktopMenuButtonTypes[] = [
|
|
58
|
-
{
|
|
59
|
-
type: 'action',
|
|
60
|
-
action: (e) => {
|
|
61
|
-
console.log('search');
|
|
62
|
-
},
|
|
63
|
-
icon: <SystemIcons.Search/>,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: 'action',
|
|
67
|
-
action: (e) => {
|
|
68
|
-
console.log('notifications');
|
|
69
|
-
},
|
|
70
|
-
icon: <SystemIcons.Notification/>,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
type: 'action',
|
|
74
|
-
action: (e) => {
|
|
75
|
-
console.log('language');
|
|
76
|
-
},
|
|
77
|
-
icon: <SystemIcons.Language/>,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: 'action',
|
|
81
|
-
action: (e) => {
|
|
82
|
-
console.log('settings');
|
|
83
|
-
},
|
|
84
|
-
icon: <SystemIcons.GearSettings/>,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
type: 'profile',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: 'action',
|
|
91
|
-
action: (e) => {
|
|
92
|
-
console.log('shop');
|
|
93
|
-
},
|
|
94
|
-
icon: <SystemIcons.ShoppingCart/>,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: 'switcher',
|
|
98
|
-
action: (e) => {
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
window.portalNav.toggle();
|
|
101
|
-
console.log('switcher')
|
|
102
|
-
},
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
const notifications: MenuNavigationItemTypeItem[] = [
|
|
107
|
-
{
|
|
108
|
-
label: 'First',
|
|
109
|
-
note: 'This is a note',
|
|
110
|
-
to: '/n7',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
label: 'Second',
|
|
114
|
-
note: 'This is a note',
|
|
115
|
-
to: '/n6',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
label: 'Third',
|
|
119
|
-
note: 'This is a note',
|
|
120
|
-
to: '/n5',
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
label: 'Fourth',
|
|
124
|
-
note: 'This is a note',
|
|
125
|
-
to: '/n4',
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
label: 'Fifth',
|
|
129
|
-
note: 'This is a note',
|
|
130
|
-
to: '/n3',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
label: 'Sixth',
|
|
134
|
-
note: 'This is a note',
|
|
135
|
-
to: '/n2',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
label: 'Seventh',
|
|
139
|
-
note: 'This is a note',
|
|
140
|
-
to: '/n1',
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
const mobileActions: MobileMenuButtonTypes[] = [
|
|
145
|
-
{
|
|
146
|
-
type: 'submenu',
|
|
147
|
-
menu: {
|
|
148
|
-
type: 'custom',
|
|
149
|
-
label: 'Search',
|
|
150
|
-
custom: () => 'custom'
|
|
151
|
-
},
|
|
152
|
-
icon: <SystemIcons.Search/>,
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
type: 'submenu',
|
|
156
|
-
menu: {
|
|
157
|
-
type: 'group',
|
|
158
|
-
label: 'Notifications',
|
|
159
|
-
items: notifications
|
|
160
|
-
},
|
|
161
|
-
icon: <SystemIcons.Notification/>,
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
type: 'action',
|
|
165
|
-
action: (e) => {
|
|
166
|
-
console.log('language');
|
|
167
|
-
return true;
|
|
168
|
-
},
|
|
169
|
-
icon: <SystemIcons.Language/>,
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
type: 'profile',
|
|
173
|
-
placement: 'left'
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
type: 'switcher',
|
|
177
|
-
action: (e) => {
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
window.portalNav.toggle();
|
|
180
|
-
console.log('switcher')
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
];
|
|
184
|
-
|
|
185
|
-
const mobileStickyNav = [
|
|
186
|
-
{
|
|
187
|
-
label: 'Help',
|
|
188
|
-
to: '/help',
|
|
189
|
-
pinned: true,
|
|
190
|
-
icon: <SystemIcons.Help/>,
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
label: 'Support',
|
|
194
|
-
to: '/support',
|
|
195
|
-
pinned: true,
|
|
196
|
-
icon: <SystemIcons.Support/>,
|
|
197
|
-
},
|
|
198
|
-
];
|
|
199
|
-
|
|
200
|
-
const accountSection = [
|
|
201
|
-
{label: 'My Account', to: '/account/myaccount', icon: <SystemIcons.User/>, external: false},
|
|
202
|
-
{label: 'Language & Region', to: '/account/language', icon: <SystemIcons.Language/>, external: false},
|
|
203
|
-
{label: 'Settings', to: '/account/settings', icon: <SystemIcons.GearSettings/>, external: false},
|
|
204
|
-
];
|
|
205
|
-
|
|
206
|
-
const organizationSection = [
|
|
207
|
-
{
|
|
208
|
-
label: 'Organization details',
|
|
209
|
-
to: '/organization/myorganization',
|
|
210
|
-
icon: <SystemIcons.Institute/>,
|
|
211
|
-
external: false
|
|
212
|
-
},
|
|
213
|
-
{label: 'People', to: '/organization/user-management', icon: <SystemIcons.Team/>, external: false},
|
|
214
|
-
];
|
|
215
|
-
|
|
216
|
-
const supportSection = [
|
|
217
|
-
{
|
|
218
|
-
label: 'Help',
|
|
219
|
-
to: 'https://laerdal.force.com/HelpCenter',
|
|
220
|
-
icon: <SystemIcons.Help/>,
|
|
221
|
-
external: true,
|
|
222
|
-
pinned: true
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
label: 'Support',
|
|
226
|
-
to: 'https://www.laerdal.com/support/',
|
|
227
|
-
icon: <SystemIcons.Support/>,
|
|
228
|
-
external: true,
|
|
229
|
-
pinned: true
|
|
230
|
-
},
|
|
231
|
-
];
|
|
232
|
-
|
|
233
|
-
const mobileNavigationSubGroup = {
|
|
234
|
-
type: 'group',
|
|
235
|
-
items: [...organizationSection, ...supportSection],
|
|
236
|
-
note: 'This is a note',
|
|
237
|
-
header: {
|
|
238
|
-
header: 'Title',
|
|
239
|
-
note: 'Note Text'
|
|
240
|
-
},
|
|
241
|
-
footer: {
|
|
242
|
-
header: 'Title',
|
|
243
|
-
note: 'Note text',
|
|
244
|
-
link: {
|
|
245
|
-
label: 'Link text',
|
|
246
|
-
href: '#',
|
|
247
|
-
external: false
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
action: {
|
|
251
|
-
label: 'Sign out',
|
|
252
|
-
action: () => {
|
|
253
|
-
console.log('Sign out');
|
|
254
|
-
},
|
|
255
|
-
icon: <SystemIcons.Logout/>
|
|
256
|
-
},
|
|
257
|
-
label: 'Organization',
|
|
258
|
-
icon: <SystemIcons.Institute/>,
|
|
259
|
-
} as MenuNavigationItemTypeGroup;
|
|
260
|
-
|
|
261
|
-
it('should render header', () => {
|
|
262
|
-
const wrapper = render(<NavigationProvider {...navProps}><MobileMenuContent header={{header: 'header', note: 'note'}}/> </NavigationProvider>)
|
|
263
|
-
|
|
264
|
-
expect(wrapper.getByText('header')).toBeDefined();
|
|
265
|
-
expect(wrapper.getByText('note')).toBeDefined();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should render footer', () => {
|
|
269
|
-
const wrapper = render(<NavigationProvider {...navProps}><MobileMenuContent
|
|
270
|
-
footer={{header: 'header', note: 'note', link: {label: 'link', href: '#'}}}/></NavigationProvider>)
|
|
271
|
-
|
|
272
|
-
expect(wrapper.getByText('header')).toBeDefined();
|
|
273
|
-
expect(wrapper.getByText('note')).toBeDefined();
|
|
274
|
-
expect(wrapper.getByText('link')).toBeDefined();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('should render action', () => {
|
|
278
|
-
const wrapper = render(<NavigationProvider {...navProps}><MobileMenuContent
|
|
279
|
-
action={{action: jest.fn(), label: 'action'}}/></NavigationProvider>)
|
|
280
|
-
|
|
281
|
-
expect(wrapper.getByText('action')).toBeDefined();
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('should render items', () => {
|
|
285
|
-
const items = [mobileNavigationSubGroup, ...mainNavigationOptions, ...mobileStickyNav]
|
|
286
|
-
const wrapper = render(<NavigationProvider {...navProps}><MobileMenuContent
|
|
287
|
-
items={items}/></NavigationProvider>)
|
|
288
|
-
|
|
289
|
-
items.forEach(item => {
|
|
290
|
-
expect(wrapper.getByText(item.label)).toBeDefined();
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
});
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {act, fireEvent, render} from '../../../test-utils';
|
|
3
|
-
import MobileMenuHeader, {MobileMenuHeaderActions, MobileMenuHeaderWrapper} from '../MobileMenuHeader';
|
|
4
|
-
import {IconButtonStyled} from '../../../Button/Iconbutton';
|
|
5
|
-
import {MobileMenuButtonTypes, ProfileMenu} from '../../types';
|
|
6
|
-
import {ProfileButtonContainer} from '../../../ProfileButton/ProfileButton';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
describe('MobileMenuHeader', () => {
|
|
13
|
-
const backSpy = jest.fn();
|
|
14
|
-
const closeSpy = jest.fn();
|
|
15
|
-
const subMenuOpenSpy = jest.fn();
|
|
16
|
-
const profileSpy = jest.fn();
|
|
17
|
-
const buttonSpy = jest.fn();
|
|
18
|
-
|
|
19
|
-
const profileButton: MobileMenuButtonTypes = {
|
|
20
|
-
type: 'profile',
|
|
21
|
-
action: profileSpy
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const subMenuButton: MobileMenuButtonTypes = {
|
|
25
|
-
type: 'submenu',
|
|
26
|
-
menu: {
|
|
27
|
-
type: 'custom',
|
|
28
|
-
custom: () => <div>custom</div>,
|
|
29
|
-
},
|
|
30
|
-
icon: <i></i>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const leftButton: MobileMenuButtonTypes = {
|
|
34
|
-
type: 'action',
|
|
35
|
-
action: buttonSpy,
|
|
36
|
-
icon: <i></i>,
|
|
37
|
-
placement: 'left'
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const rightButton: MobileMenuButtonTypes = {
|
|
41
|
-
type: 'action',
|
|
42
|
-
action: buttonSpy,
|
|
43
|
-
icon: <i></i>,
|
|
44
|
-
placement: 'right'
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
backSpy.mockReset();
|
|
49
|
-
closeSpy.mockReset();
|
|
50
|
-
subMenuOpenSpy.mockReset();
|
|
51
|
-
buttonSpy.mockReset();
|
|
52
|
-
profileSpy.mockReset();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should render', () => {
|
|
56
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy}/>)
|
|
57
|
-
|
|
58
|
-
expect(wrapper.container.querySelector(`${MobileMenuHeaderWrapper}`)).toBeDefined();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should render only close button', () => {
|
|
62
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy}/>)
|
|
63
|
-
|
|
64
|
-
expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(1);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should render label', () => {
|
|
68
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} label={'label'}/>)
|
|
69
|
-
|
|
70
|
-
expect(wrapper.queryByText('label')).toBeDefined();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should render close button and back button', () => {
|
|
74
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} onGoBack={backSpy}/>)
|
|
75
|
-
|
|
76
|
-
expect(wrapper.container.querySelectorAll(`${IconButtonStyled}`)).toHaveLength(2);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should render profile button', () => {
|
|
80
|
-
|
|
81
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} profile={
|
|
82
|
-
{
|
|
83
|
-
user:{
|
|
84
|
-
firstName: "name",
|
|
85
|
-
lastName: "last",
|
|
86
|
-
email: "mail",
|
|
87
|
-
},
|
|
88
|
-
sections:[]
|
|
89
|
-
}
|
|
90
|
-
} buttons={[profileButton]}/>)
|
|
91
|
-
|
|
92
|
-
expect(wrapper.container.querySelectorAll(`${ProfileButtonContainer}`)).toHaveLength(1);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should render button on the left', () => {
|
|
96
|
-
|
|
97
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} buttons={[leftButton]}/>)
|
|
98
|
-
|
|
99
|
-
expect(wrapper.container.querySelectorAll(`${MobileMenuHeaderWrapper} ${IconButtonStyled}`)).toHaveLength(2);
|
|
100
|
-
expect(wrapper.container.querySelectorAll(`${MobileMenuHeaderActions} ${IconButtonStyled}`)).toHaveLength(1);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should render button on the right', () => {
|
|
104
|
-
|
|
105
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} buttons={[rightButton]}/>)
|
|
106
|
-
|
|
107
|
-
expect(wrapper.container.querySelectorAll(`${MobileMenuHeaderWrapper} ${IconButtonStyled}`)).toHaveLength(2);
|
|
108
|
-
expect(wrapper.container.querySelectorAll(`${MobileMenuHeaderActions} ${IconButtonStyled}`)).toHaveLength(2);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should call onClose function when close button is clicked', () => {
|
|
112
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy}/>)
|
|
113
|
-
|
|
114
|
-
act(() => {
|
|
115
|
-
fireEvent.click(wrapper.container.querySelector(`${IconButtonStyled}`)!);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(closeSpy).toHaveBeenCalled();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should call onGoBack function when back button is clicked', () => {
|
|
122
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} onGoBack={backSpy}/>)
|
|
123
|
-
|
|
124
|
-
act(() => {
|
|
125
|
-
fireEvent.click(wrapper.container.querySelectorAll(`${IconButtonStyled}`)[0]);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
expect(backSpy).toHaveBeenCalled();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should call onSubMenuOpen function when submenu button is clicked', () => {
|
|
132
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} buttons={[subMenuButton]}
|
|
133
|
-
onSubMenuOpen={subMenuOpenSpy}/>)
|
|
134
|
-
|
|
135
|
-
act(() => {
|
|
136
|
-
fireEvent.click(wrapper.container.querySelectorAll(`${IconButtonStyled}`)[0]);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
expect(subMenuOpenSpy).toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should call action when icon button is clicked', () => {
|
|
143
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} buttons={[leftButton]}/>)
|
|
144
|
-
|
|
145
|
-
act(() => {
|
|
146
|
-
fireEvent.click(wrapper.container.querySelectorAll(`${IconButtonStyled}`)[0]);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
expect(buttonSpy).toHaveBeenCalled();
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should call profile button action when profile button is clicked', () => {
|
|
153
|
-
|
|
154
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy} profile={
|
|
155
|
-
{
|
|
156
|
-
user:{
|
|
157
|
-
firstName: "name",
|
|
158
|
-
lastName: "last",
|
|
159
|
-
email: "mail",
|
|
160
|
-
},
|
|
161
|
-
sections:[]
|
|
162
|
-
}
|
|
163
|
-
} buttons={[profileButton]}/>)
|
|
164
|
-
|
|
165
|
-
act(() => {
|
|
166
|
-
fireEvent.click(wrapper.container.querySelectorAll(`${IconButtonStyled}`)[0]);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
expect(profileSpy).toHaveBeenCalled();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('should call onSubMenuOpen when profile button is clicked and action is not provided', () => {
|
|
173
|
-
const profile = {
|
|
174
|
-
label: 'profile label',
|
|
175
|
-
sections: [],
|
|
176
|
-
user: {
|
|
177
|
-
lastName: 'lastname',
|
|
178
|
-
firstName: 'firstname',
|
|
179
|
-
email: 'email@email.com'
|
|
180
|
-
},
|
|
181
|
-
} as ProfileMenu;
|
|
182
|
-
const wrapper = render(<MobileMenuHeader onClose={closeSpy}
|
|
183
|
-
buttons={[{...profileButton, action: undefined}]}
|
|
184
|
-
profile={profile}
|
|
185
|
-
onSubMenuOpen={subMenuOpenSpy}/>)
|
|
186
|
-
|
|
187
|
-
act(() => {
|
|
188
|
-
fireEvent.click(wrapper.container.querySelectorAll(`${IconButtonStyled}`)[0]);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
expect(subMenuOpenSpy).toHaveBeenCalled();
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {render} from '../../test-utils';
|
|
3
|
-
import {Size, States} from '../../types';
|
|
4
|
-
import 'jest-styled-components';
|
|
5
|
-
import {COLORS, NumberField} from '../..';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe('<NumberField />', () => {
|
|
9
|
-
|
|
10
|
-
it('renders note field', async () => {
|
|
11
|
-
const { getByText } = render(
|
|
12
|
-
<NumberField type='NumberField' note='test note' size={Size.Medium}/>
|
|
13
|
-
);
|
|
14
|
-
expect(getByText('test note')).toBeDefined();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('renders required asterisk', async () => {
|
|
18
|
-
const { queryByTestId } = render(
|
|
19
|
-
<NumberField type='NumberField' dataTestId='numberInput' required size={Size.Medium}/>
|
|
20
|
-
);
|
|
21
|
-
expect(queryByTestId('labelIcon')).toBeDefined();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('does not renders required asterisk', async () => {
|
|
25
|
-
const { queryByTestId } = render(
|
|
26
|
-
<NumberField type='NumberField' dataTestId='numberInput' size={Size.Medium}/>
|
|
27
|
-
);
|
|
28
|
-
expect(queryByTestId('labelIcon')).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders positive note and input container', async () => {
|
|
32
|
-
const { container, getByTestId } = render(
|
|
33
|
-
<NumberField type='NumberField' dataTestId='numberInput' note='test note' state={States.Valid} size={Size.Medium}/>
|
|
34
|
-
);
|
|
35
|
-
expect(container.getElementsByClassName('valid').length).toBe(1);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('renders warning note and input container', async () => {
|
|
39
|
-
const { container, getByTestId } = render(
|
|
40
|
-
<NumberField type='NumberField' dataTestId='numberInput' note='test note' state={States.Invalid} size={Size.Medium}/>
|
|
41
|
-
);
|
|
42
|
-
expect(container.getElementsByClassName('invalid').length).toBe(1);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('renders correct disabled input container', async () => {
|
|
46
|
-
const { getByTestId } = render(
|
|
47
|
-
<NumberField type='NumberField' dataTestId='numberInput' size={Size.Small}/>
|
|
48
|
-
);
|
|
49
|
-
expect(getByTestId('numberInput')).toHaveStyleRule('cursor', `not-allowed`, {modifier:'&.disabled'});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('renders correct readonly input container', async () => {
|
|
53
|
-
const { getByTestId } = render(
|
|
54
|
-
<NumberField type='NumberField' dataTestId='numberInput' size={Size.Small}/>
|
|
55
|
-
);
|
|
56
|
-
expect(getByTestId('numberInput')).toHaveStyleRule('cursor', `not-allowed`, {modifier:'&.readOnly'});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('renders operators in the input container', async () => {
|
|
60
|
-
const { getByTestId } = render(
|
|
61
|
-
<NumberField type='NumberField' dataTestId='numberInput' size={Size.Medium}/>
|
|
62
|
-
);
|
|
63
|
-
expect(getByTestId('operators').childElementCount).toBe(3);
|
|
64
|
-
expect(getByTestId('operators').firstChild).toBeDefined();
|
|
65
|
-
expect(getByTestId('operators').lastChild).toBeDefined();
|
|
66
|
-
})
|
|
67
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '../../test-utils';
|
|
3
|
-
import {Size, States} from '../../types';
|
|
4
|
-
import 'jest-styled-components';
|
|
5
|
-
import { COLORS, NumberField } from '../..';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe('<NumberField />', () => {
|
|
9
|
-
|
|
10
|
-
it('renders note field', async () => {
|
|
11
|
-
const { getByText } = render(
|
|
12
|
-
<NumberField type='NumberInput' note='test note' size={Size.Medium}/>
|
|
13
|
-
);
|
|
14
|
-
expect(getByText('test note')).toBeDefined();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('renders required asterisk', async () => {
|
|
18
|
-
const { queryByTestId } = render(
|
|
19
|
-
<NumberField type='NumberInput' required size={Size.Medium}/>
|
|
20
|
-
);
|
|
21
|
-
expect(queryByTestId('labelIcon')).toBeDefined();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('does not renders required asterisk', async () => {
|
|
25
|
-
const { queryByTestId } = render(
|
|
26
|
-
<NumberField type='NumberInput' size={Size.Medium}/>
|
|
27
|
-
);
|
|
28
|
-
expect(queryByTestId('labelIcon')).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('renders positive note and input container', async () => {
|
|
32
|
-
const { container, getByTestId } = render(
|
|
33
|
-
<NumberField type='NumberInput' dataTestId='numberInput' note='test note' state={States.Valid} size={Size.Medium}/>
|
|
34
|
-
);
|
|
35
|
-
expect(container.getElementsByClassName('valid').length).toBe(1);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('renders warning note and input container', async () => {
|
|
39
|
-
const { container, getByTestId } = render(
|
|
40
|
-
<NumberField type='NumberInput' dataTestId='numberInput' note='test note' state={States.Invalid} size={Size.Medium}/>
|
|
41
|
-
);
|
|
42
|
-
expect(container.getElementsByClassName('invalid').length).toBe(1);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('renders correct disabled input container', async () => {
|
|
46
|
-
const { getByTestId } = render(
|
|
47
|
-
<NumberField type='NumberInput' dataTestId='numberInput' size={Size.Small}/>
|
|
48
|
-
);
|
|
49
|
-
expect(getByTestId('numberInput')).toHaveStyleRule('cursor', `not-allowed`, {modifier:'&.disabled'});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('renders correct readonly input container', async () => {
|
|
53
|
-
const { getByTestId } = render(
|
|
54
|
-
<NumberField type='NumberInput' dataTestId='numberInput' size={Size.Small}/>
|
|
55
|
-
);
|
|
56
|
-
expect(getByTestId('numberInput')).toHaveStyleRule('cursor', `not-allowed`, {modifier:'&.readOnly'});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('renders operators in the input container', async () => {
|
|
60
|
-
const { getByTestId } = render(
|
|
61
|
-
<NumberField type='NumberInput' size={Size.Medium}/>
|
|
62
|
-
);
|
|
63
|
-
expect(getByTestId('leftOperator')).toHaveStyleRule('left', '0');
|
|
64
|
-
expect(getByTestId('leftOperator')).toHaveStyleRule('top', '4px');
|
|
65
|
-
expect(getByTestId('rightOperator')).toHaveStyleRule('right', '0');
|
|
66
|
-
expect(getByTestId('rightOperator')).toHaveStyleRule('top', '4px');
|
|
67
|
-
})
|
|
68
|
-
})
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { findByTestId, render } from '../../test-utils';
|
|
3
|
-
import {Size} from '../../types';
|
|
4
|
-
import 'jest-styled-components';
|
|
5
|
-
import { QuickSearch } from '..';
|
|
6
|
-
import { ThemeProvider } from 'styled-components';
|
|
7
|
-
|
|
8
|
-
describe('<QuickSearch />', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
it('Renders quick search', async () => {
|
|
12
|
-
let search = '';
|
|
13
|
-
let searchEntered = false;
|
|
14
|
-
const { queryByText, getByTestId, queryAllByTestId, container } = render(
|
|
15
|
-
<ThemeProvider theme={{}}>
|
|
16
|
-
<div style={{ width: '400px' }}>
|
|
17
|
-
<QuickSearch
|
|
18
|
-
id="QuickSearch"
|
|
19
|
-
size={Size.Small}
|
|
20
|
-
enterSearch={() => {
|
|
21
|
-
searchEntered = true;
|
|
22
|
-
}}
|
|
23
|
-
removeSearch={() => {
|
|
24
|
-
search = '';
|
|
25
|
-
}}
|
|
26
|
-
setSearchTerm={(term) => {
|
|
27
|
-
search = term;
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
</div></ThemeProvider>,
|
|
31
|
-
);
|
|
32
|
-
expect(getByTestId('QuickSearch_main').classList.contains('small')).toBeTruthy();
|
|
33
|
-
expect(getByTestId('QuickSearch_Searchbutton')).toBeDefined();
|
|
34
|
-
|
|
35
|
-
// Test click on icon and check that input field shows
|
|
36
|
-
expect(queryAllByTestId('QuickSearch').length).toBe(0);
|
|
37
|
-
(await findByTestId(container, 'QuickSearch_Searchbutton') as HTMLButtonElement)?.click();
|
|
38
|
-
expect(await findByTestId(container, 'QuickSearch_main')).toBeDefined();
|
|
39
|
-
expect(getByTestId('QuickSearch_main').classList.contains('expanded')).toBeTruthy();
|
|
40
|
-
expect(getByTestId('QuickSearch_Clearicon').parentElement).toHaveProperty('hidden');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {render} from '../../test-utils';
|
|
3
|
-
import LinearProgress, {Bar, Dot, Line, LinearProgressType, LineFill} from '../LinearProgress';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe('LinearProgress', () => {
|
|
8
|
-
it('should render dots', () => {
|
|
9
|
-
const wrapper = render(<LinearProgress type={LinearProgressType.Dots} max={11} value={6}/>);
|
|
10
|
-
expect(wrapper.container.querySelectorAll(`${Dot}`)).toHaveLength(11)
|
|
11
|
-
expect(wrapper.container.querySelectorAll(`${Dot}.active`)).toHaveLength(6)
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should render bars', () => {
|
|
15
|
-
const wrapper = render(<LinearProgress type={LinearProgressType.Bars} max={11} value={6}/>);
|
|
16
|
-
expect(wrapper.container.querySelectorAll(`${Bar}`)).toHaveLength(11)
|
|
17
|
-
expect(wrapper.container.querySelectorAll(`${Bar}.active`)).toHaveLength(6)
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should render line', () => {
|
|
21
|
-
const wrapper = render(<LinearProgress type={LinearProgressType.Line} max={11} value={6}/>);
|
|
22
|
-
expect(wrapper.container.querySelectorAll(`${Line}`)).toHaveLength(1)
|
|
23
|
-
expect(wrapper.container.querySelectorAll(`${LineFill}`).item(0).getAttribute('style')).toEqual(`width: ${6 / 11 * 100}%;`)
|
|
24
|
-
});
|
|
25
|
-
});
|