@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,155 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, fireEvent, render, RenderResult } from '../../test-utils';
|
|
3
|
-
import { ChipInput, Size } from '../..';
|
|
4
|
-
import '../../../jest.setup';
|
|
5
|
-
|
|
6
|
-
const list = ['Contact', 'About', 'Base', 'Blog', 'Custom', 'Support', 'Tools'];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('<ChipInput />', () => {
|
|
11
|
-
it('Render component correctly', async () => {
|
|
12
|
-
let componentResult: RenderResult;
|
|
13
|
-
|
|
14
|
-
//initial values are determined by using multiple hooks (useEffect)
|
|
15
|
-
//in order to be sure we get the last rendered version of the component, we need to wait for it
|
|
16
|
-
await act(async () => {
|
|
17
|
-
componentResult = render(
|
|
18
|
-
<ChipInput size={Size.Medium} inputId="utest" values={[list[0]]} onValueChange={() => {}} placeholder="Plchd label" altPlaceholder="Alt plchd label" />,
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
//check element wrapper component rendered
|
|
22
|
-
expect(componentResult!.getByTestId('chip-input-container')).toBeTruthy();
|
|
23
|
-
//check correct placeholder displayed
|
|
24
|
-
expect(componentResult!.getByPlaceholderText('Alt plchd label') as HTMLInputElement).toBeTruthy();
|
|
25
|
-
//check chip input with provided id rendered
|
|
26
|
-
expect(componentResult!.container.querySelector('input[id="utest"]')).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('Render component with correct size', async () => {
|
|
30
|
-
let componentResult: RenderResult;
|
|
31
|
-
|
|
32
|
-
await act(async () => {
|
|
33
|
-
componentResult = render(
|
|
34
|
-
<ChipInput size={Size.Small} inputId="utest" values={[list[0]]} onValueChange={() => {}} placeholder="Plchd label" altPlaceholder="Alt plchd label" />,
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
//check element wrapper component rendered
|
|
38
|
-
expect(componentResult!.getByTestId('chip-input-container')).toBeTruthy();
|
|
39
|
-
|
|
40
|
-
//check element has correct class size present
|
|
41
|
-
expect(componentResult!.getByTestId('chip-input-container')).toHaveClass('small');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Test component focused on click', async () => {
|
|
45
|
-
let componentResult: RenderResult;
|
|
46
|
-
|
|
47
|
-
//initial values are determined by using multiple hooks (useEffect)
|
|
48
|
-
//in order to be sure we get the last rendered version of the component, we need to wait for it
|
|
49
|
-
await act(async () => {
|
|
50
|
-
componentResult = render(
|
|
51
|
-
<ChipInput size={Size.Small} inputId="utest" values={[list[0]]} onValueChange={() => {}} placeholder="Plchd label" altPlaceholder="Alt plchd label" />,
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
//check element wrapper component rendered
|
|
55
|
-
expect(componentResult!.getByTestId('chip-input-container')).toBeTruthy();
|
|
56
|
-
|
|
57
|
-
//check focus not present
|
|
58
|
-
expect(componentResult!.getByPlaceholderText('Alt plchd label') as HTMLInputElement).not.toHaveFocus();
|
|
59
|
-
|
|
60
|
-
//trigger click for chip input
|
|
61
|
-
fireEvent.click(componentResult!.getByTestId('chip-input-container'));
|
|
62
|
-
|
|
63
|
-
//check focus present
|
|
64
|
-
expect(componentResult!.getByPlaceholderText('Alt plchd label') as HTMLInputElement).toHaveFocus();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('Test component callbacks', async () => {
|
|
68
|
-
const onValueChange = jest.fn();
|
|
69
|
-
let componentResult: RenderResult;
|
|
70
|
-
|
|
71
|
-
//initial values are determined by using multiple hooks (useEffect)
|
|
72
|
-
//in order to be sure we get the last rendered version of the component, we need to wait for it
|
|
73
|
-
await act(async () => {
|
|
74
|
-
componentResult = render(
|
|
75
|
-
<ChipInput size={Size.Small} inputId="utest" values={[list[0]]} onValueChange={onValueChange} placeholder="Plchd label" altPlaceholder="Alt plchd label" />,
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
//mock scrollIntoView otherwise test will fail when selecting an item
|
|
80
|
-
window.HTMLElement.prototype.scrollIntoView = function () {};
|
|
81
|
-
|
|
82
|
-
const inputElem = componentResult!.getByPlaceholderText('Alt plchd label') as HTMLInputElement;
|
|
83
|
-
|
|
84
|
-
//check element wrapper component rendered
|
|
85
|
-
expect(componentResult!.getByTestId('chip-input-container')).toBeTruthy();
|
|
86
|
-
|
|
87
|
-
//trigger click for chip input
|
|
88
|
-
fireEvent.click(componentResult!.getByTestId('chip-input-container'));
|
|
89
|
-
|
|
90
|
-
//trigger value change
|
|
91
|
-
fireEvent.change(inputElem, { target: { value: list[1] } });
|
|
92
|
-
|
|
93
|
-
//pressing enter will automatically select the found item
|
|
94
|
-
fireEvent.keyDown(inputElem, { key: 'Enter', code: 'Enter', charCode: 13 });
|
|
95
|
-
|
|
96
|
-
expect(onValueChange).toHaveBeenCalledTimes(1);
|
|
97
|
-
|
|
98
|
-
//two items present, default and the new selected one
|
|
99
|
-
expect(componentResult!.container.querySelectorAll('.chip-icon')).toHaveLength(2);
|
|
100
|
-
|
|
101
|
-
//pressing on the x button, the item will be removed from selection
|
|
102
|
-
const removeItemElem = componentResult!.getByTestId('chip-input-container').querySelector('div.chip-icon') as HTMLDivElement;
|
|
103
|
-
|
|
104
|
-
fireEvent.click(removeItemElem);
|
|
105
|
-
|
|
106
|
-
//change callback should be called
|
|
107
|
-
expect(onValueChange).toHaveBeenCalledTimes(2);
|
|
108
|
-
//only one item should be present at the moment
|
|
109
|
-
expect(componentResult!.container.querySelectorAll('.chip-icon')).toHaveLength(1);
|
|
110
|
-
|
|
111
|
-
//expect that on pressing backspace the added item will be deleted
|
|
112
|
-
fireEvent.keyDown(inputElem, { key: 'Backspace', charCode: 8 });
|
|
113
|
-
|
|
114
|
-
//no item should be present at the moment
|
|
115
|
-
expect(componentResult!.container.querySelectorAll('.chip-icon')).toHaveLength(0);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('Test component chips are removed when clear all button toggled', async () => {
|
|
119
|
-
const onValueChange = jest.fn();
|
|
120
|
-
let componentResult: RenderResult;
|
|
121
|
-
|
|
122
|
-
//initial values are determined by using multiple hooks (useEffect)
|
|
123
|
-
//in order to be sure we get the last rendered version of the component, we need to wait for it
|
|
124
|
-
await act(async () => {
|
|
125
|
-
componentResult = render(
|
|
126
|
-
<ChipInput size={Size.Small} inputId="utest" values={[list[0]]} onValueChange={onValueChange} placeholder="Plchd label" altPlaceholder="Alt plchd label" />,
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
//check element wrapper component rendered
|
|
131
|
-
expect(componentResult!.getByTestId('chip-input-container')).toBeTruthy();
|
|
132
|
-
|
|
133
|
-
//one item present, the default one
|
|
134
|
-
expect(componentResult!.container.querySelectorAll('.chip-icon')).toHaveLength(1);
|
|
135
|
-
const input = componentResult!.getByPlaceholderText('Alt plchd label') as HTMLInputElement;
|
|
136
|
-
|
|
137
|
-
const mockInputData = 'mock data';
|
|
138
|
-
//trigger value change
|
|
139
|
-
fireEvent.change(input, { target: { value: mockInputData } });
|
|
140
|
-
|
|
141
|
-
expect(input).toHaveValue(mockInputData);
|
|
142
|
-
|
|
143
|
-
//expect clear button to be displayed
|
|
144
|
-
expect(componentResult!.getByTestId('clear-btn-utest')).toBeTruthy();
|
|
145
|
-
|
|
146
|
-
//press on clear button
|
|
147
|
-
fireEvent.click(componentResult!.getByTestId('clear-btn-utest'));
|
|
148
|
-
|
|
149
|
-
//expect input to have no value
|
|
150
|
-
expect(input).toHaveValue('');
|
|
151
|
-
|
|
152
|
-
//one chip selected
|
|
153
|
-
expect(componentResult!.container.querySelectorAll('.chip-icon')).toHaveLength(1);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '../../test-utils';
|
|
3
|
-
import { DropdownFilter } from '../index';
|
|
4
|
-
|
|
5
|
-
jest.mock('react-resize-detector', () => ({
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
...jest.requireActual('react-resize-detector'),
|
|
8
|
-
useResizeDetector: (object: any) => ({ height: 100, width: 120})
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const list = [{value: 'Contact'},
|
|
15
|
-
{value: 'About'},
|
|
16
|
-
{value: 'Base'},
|
|
17
|
-
{value: 'Blog'},
|
|
18
|
-
{value: 'Contact 3'},
|
|
19
|
-
{value: 'Custom'},
|
|
20
|
-
{value: 'Support'},
|
|
21
|
-
{value: 'Tools'}];
|
|
22
|
-
|
|
23
|
-
describe('<DropdownFilter />', () => {
|
|
24
|
-
it('Renders with no default value', async () => {
|
|
25
|
-
const { getByPlaceholderText } = render(<DropdownFilter id="Dropdown" list={list} placeholder="Placeholder" />);
|
|
26
|
-
expect((getByPlaceholderText('Placeholder') as HTMLInputElement).value).toBe('');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('Renders with required input if specified', async () => {
|
|
30
|
-
const { getByPlaceholderText } = render(<DropdownFilter id="Dropdown" list={list} placeholder="Placeholder" required />);
|
|
31
|
-
expect((getByPlaceholderText('Placeholder') as HTMLInputElement).required).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('Renders with inital value if specified', async () => {
|
|
35
|
-
const initialValue = 'Contact';
|
|
36
|
-
const { getByPlaceholderText } = render(<DropdownFilter id="Dropdown" list={list} placeholder="Placeholder" value={initialValue} />);
|
|
37
|
-
expect((getByPlaceholderText('Placeholder') as HTMLInputElement).value).toBe(initialValue);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '../../test-utils';
|
|
3
|
-
import 'jest-styled-components';
|
|
4
|
-
import Footer from '../Footer';
|
|
5
|
-
import { COLORS } from '../../styles';
|
|
6
|
-
import SiteFooter from '../SiteFooter';
|
|
7
|
-
import FooterDropdownLinks from '../Components/FooterDropdownLinks';
|
|
8
|
-
|
|
9
|
-
const animate = require('animated-scroll-to');
|
|
10
|
-
|
|
11
|
-
jest.mock('react-resize-detector', () => ({
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
...jest.requireActual('react-resize-detector'),
|
|
14
|
-
useResizeDetector: (object: any) => ({ height: 100, width: 120})
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const scrollSpy = jest.fn()
|
|
18
|
-
animate.default = scrollSpy;
|
|
19
|
-
|
|
20
|
-
describe('<Footer />',()=>{
|
|
21
|
-
beforeEach(()=>scrollSpy.mockReset());
|
|
22
|
-
|
|
23
|
-
it('renders footer', async () => {
|
|
24
|
-
const{getByText} = render(
|
|
25
|
-
<Footer>
|
|
26
|
-
<div>Test Footer</div>
|
|
27
|
-
</Footer>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
expect(getByText('Test Footer')).toBeDefined();
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('renders footer global content', async () => {
|
|
34
|
-
const{getByTestId} = render(
|
|
35
|
-
<Footer>
|
|
36
|
-
<div>Test Footer</div>
|
|
37
|
-
</Footer>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(getByTestId('footer-content')).toBeDefined();
|
|
41
|
-
expect(getByTestId('footer-content')).toHaveStyleRule('background-color',COLORS.primary_700);
|
|
42
|
-
expect(getByTestId('footer-content')).toHaveStyleRule('min-height','8px');
|
|
43
|
-
expect(getByTestId('footer-content')).toHaveStyleRule('color','white');
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('renders site footer', async () => {
|
|
47
|
-
const{getByTestId} = render(
|
|
48
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top'/>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
expect(getByTestId('footer-container')).toBeDefined();
|
|
52
|
-
expect(getByTestId('footer-container')).toHaveStyleRule('background-color', COLORS.neutral_800);
|
|
53
|
-
expect(getByTestId('footer-container')).toHaveStyleRule('border-top', `8px solid ${COLORS.neutral_200}`);
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('renders site footer to top text', async () => {
|
|
57
|
-
const{getByText} = render(
|
|
58
|
-
|
|
59
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top'/>
|
|
60
|
-
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(getByText('Scroll To Top')).toBeDefined();
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('performs navigation on click', async () => {
|
|
67
|
-
const{getByTestId} = render(
|
|
68
|
-
|
|
69
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top'/>
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
fireEvent.click(getByTestId('toTopNavigation'));
|
|
74
|
-
expect(scrollSpy).toHaveBeenCalledWith(0);
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it('performs navigation on enter', async () => {
|
|
78
|
-
const{getByTestId} = render(
|
|
79
|
-
|
|
80
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top'/>
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
fireEvent.keyDown(getByTestId('toTopNavigation'), {key: 'Enter', code: 'Enter', charCode: 13});
|
|
85
|
-
expect(scrollSpy).toHaveBeenCalledWith(0);
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('does not performs navigation on key other than enter', async () => {
|
|
89
|
-
const{getByTestId} = render(
|
|
90
|
-
|
|
91
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top'/>
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
fireEvent.keyDown(getByTestId('toTopNavigation'), {key: 'A', code: 'KeyA'});
|
|
96
|
-
expect(scrollSpy).not.toHaveBeenCalled();
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('renders site footer copyright', async () => {
|
|
100
|
-
const{getByText} = render(
|
|
101
|
-
|
|
102
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top' copyrightText='this is copyright'/>
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
expect(getByText('this is copyright')).toBeDefined();
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('renders site footer links', async () => {
|
|
110
|
-
const{getByText} = render(
|
|
111
|
-
|
|
112
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top' bottomLinks={[{label:'testLabel', to:'target'}]}/>
|
|
113
|
-
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
expect(getByText('testLabel')).toBeDefined();
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('renders site footer nav section', async () => {
|
|
120
|
-
const{getByText} = render(
|
|
121
|
-
|
|
122
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top' navOptions={{sections:[{header:'headerText',links:[{label:'labelText',to:'target'}]}]}}/>
|
|
123
|
-
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
expect(getByText('headerText')).toBeDefined();
|
|
127
|
-
expect(getByText('labelText')).toBeDefined();
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it('renders site footer newsletter and social section', async () => {
|
|
131
|
-
const signUpFn = jest.fn();
|
|
132
|
-
|
|
133
|
-
const{getByText, getByTestId, getByPlaceholderText} = render(
|
|
134
|
-
|
|
135
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top' includeNewsletterAndSocialSection={true}
|
|
136
|
-
placeholderEmailField='a@a.com' newsletterLabel='new news'
|
|
137
|
-
onNewsletterSignup={(e)=>signUpFn(e)}/>
|
|
138
|
-
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
expect(getByPlaceholderText('a@a.com')).toBeDefined();
|
|
142
|
-
expect(getByText('new news')).toBeDefined();
|
|
143
|
-
|
|
144
|
-
fireEvent.click(getByTestId('newsBtn'));
|
|
145
|
-
expect(signUpFn).toBeCalledTimes(1);
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('updates newsletter email', async () => {
|
|
149
|
-
const{getByText, getByPlaceholderText} = render(
|
|
150
|
-
|
|
151
|
-
<SiteFooter id='testFooter' toTopText='Scroll To Top' includeNewsletterAndSocialSection={true}
|
|
152
|
-
placeholderEmailField='a@a.com' newsletterLabel='new news' />
|
|
153
|
-
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
expect(getByPlaceholderText('a@a.com')).toBeDefined();
|
|
157
|
-
expect(getByText('new news')).toBeDefined();
|
|
158
|
-
fireEvent.change(getByPlaceholderText('a@a.com'), {target: {value: 'abc'}});
|
|
159
|
-
expect((getByPlaceholderText('a@a.com') as HTMLInputElement).value).toBe('abc');
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('renders site footer dropdown links', async () => {
|
|
163
|
-
const{getByText} = render(
|
|
164
|
-
<FooterDropdownLinks navSection={{header:'sample header', links:[{label:'labelText', to:'labelTarget'}]}} width={200}/>
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
expect(getByText('sample header')).toBeDefined();
|
|
168
|
-
expect(getByText('labelText')).toBeDefined();
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
it('opens dropdown links on mouse click', async () => {
|
|
172
|
-
const{getByRole} = render(
|
|
173
|
-
<FooterDropdownLinks navSection={{header:'sample header', links:[{label:'labelText', to:'labelTarget'}]}} width={200}/>
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
expect(getByRole('button')).toBeDefined();
|
|
177
|
-
fireEvent.click(getByRole('button'));
|
|
178
|
-
expect(getByRole('button').classList.contains('open')).toBe(true);
|
|
179
|
-
fireEvent.click(getByRole('button'));
|
|
180
|
-
expect(getByRole('button').classList.contains('open')).toBe(false);
|
|
181
|
-
})
|
|
182
|
-
})
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {act, fireEvent, render} from '../../test-utils';
|
|
3
|
-
import Logo from '../Logo';
|
|
4
|
-
import { NavigationProvider } from '../../Navigation';
|
|
5
|
-
|
|
6
|
-
describe('Logo', () => {
|
|
7
|
-
|
|
8
|
-
const navProps = {
|
|
9
|
-
currentPath: '',
|
|
10
|
-
isActiveRoute: () => false,
|
|
11
|
-
navigate: (path: string, isExternal: boolean) => {}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
it('should render Laerdal logo', () => {
|
|
16
|
-
const wrapper = render(<NavigationProvider {...navProps}><Logo name={'name'}/></NavigationProvider>);
|
|
17
|
-
|
|
18
|
-
expect(wrapper.getByText('name')).toBeDefined();
|
|
19
|
-
expect(wrapper.getByText('Laerdal logo')).toBeDefined();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should render beta tag', () => {
|
|
23
|
-
const wrapper = render(<NavigationProvider {...navProps}><Logo name={'name'} showBetaTag={true}/></NavigationProvider>);
|
|
24
|
-
|
|
25
|
-
expect(wrapper.getByText('BETA')).toBeDefined();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should call onClick when logo is clicked', () => {
|
|
29
|
-
const onClickSpy = jest.fn();
|
|
30
|
-
const wrapper = render(<NavigationProvider {...navProps}><Logo name={'name'} onClick={onClickSpy}/></NavigationProvider>);
|
|
31
|
-
|
|
32
|
-
act(() => {
|
|
33
|
-
fireEvent.click(wrapper.container.querySelector('a')!);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(onClickSpy).toHaveBeenCalled();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
});
|
|
@@ -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
|
-
});
|