@laerdal/life-react-components 3.6.0-dev.1.full → 3.6.1
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/Accordion/__tests__/AccordionMenu.test.tsx +42 -0
- package/dist/Accordion/__tests__/ContentAccordion.test.tsx +150 -0
- package/dist/AuthPage/__tests__/AuthPage.test.tsx +27 -0
- package/dist/Banners/__tests__/Banner.test.tsx +47 -0
- package/dist/Banners/__tests__/OverviewBanner.test.tsx +20 -0
- package/dist/Breadcrumb/__tests__/Breadcrumb.test.tsx +78 -0
- package/dist/Button/TextButton.cjs +648 -0
- package/dist/Button/TextButton.cjs.map +1 -0
- package/dist/Button/TextButton.d.ts +77 -0
- package/dist/Button/TextButton.js +640 -0
- package/dist/Button/TextButton.js.map +1 -0
- package/dist/Button/__tests__/BackButton.test.tsx +32 -0
- package/dist/Button/__tests__/Button.test.tsx +45 -0
- package/dist/Button/__tests__/DualButton.test.tsx +119 -0
- package/dist/Button/__tests__/TextButton.test.tsx +45 -0
- package/dist/Card/HorizontalCard/__tests__/HorizontalCard.test.tsx +71 -0
- package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +124 -0
- package/dist/Card/VerticalCard/VerticalCard.cjs +187 -0
- package/dist/Card/VerticalCard/VerticalCard.cjs.map +1 -0
- package/dist/Card/VerticalCard/VerticalCard.d.ts +25 -0
- package/dist/Card/VerticalCard/VerticalCard.js +178 -0
- package/dist/Card/VerticalCard/VerticalCard.js.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardBottomSection.cjs +261 -0
- package/dist/Card/VerticalCard/VerticalCardBottomSection.cjs.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardBottomSection.d.ts +53 -0
- package/dist/Card/VerticalCard/VerticalCardBottomSection.js +252 -0
- package/dist/Card/VerticalCard/VerticalCardBottomSection.js.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardMiddleSection.cjs +145 -0
- package/dist/Card/VerticalCard/VerticalCardMiddleSection.cjs.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardMiddleSection.d.ts +42 -0
- package/dist/Card/VerticalCard/VerticalCardMiddleSection.js +136 -0
- package/dist/Card/VerticalCard/VerticalCardMiddleSection.js.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardTopSection.cjs +165 -0
- package/dist/Card/VerticalCard/VerticalCardTopSection.cjs.map +1 -0
- package/dist/Card/VerticalCard/VerticalCardTopSection.d.ts +45 -0
- package/dist/Card/VerticalCard/VerticalCardTopSection.js +156 -0
- package/dist/Card/VerticalCard/VerticalCardTopSection.js.map +1 -0
- package/dist/Card/VerticalCard/__tests__/VerticalCard.test.tsx +124 -0
- package/dist/Card/__tests__/Card.test.tsx +146 -0
- package/dist/Chips/ChoiceChips.cjs +0 -1
- package/dist/Chips/ChoiceChips.cjs.map +1 -1
- package/dist/Chips/ChoiceChips.js +0 -1
- package/dist/Chips/ChoiceChips.js.map +1 -1
- package/dist/Chips/__tests__/ActionChip.test.tsx +94 -0
- package/dist/Chips/__tests__/ChoiceChips.test.tsx +79 -0
- package/dist/Chips/__tests__/FilterChip.test.tsx +95 -0
- package/dist/Chips/__tests__/InputChip.test.tsx +155 -0
- package/dist/ChipsInput/ChipDropdownInput.cjs +1 -1
- package/dist/ChipsInput/ChipDropdownInput.cjs.map +1 -1
- package/dist/ChipsInput/ChipDropdownInput.js +1 -1
- package/dist/ChipsInput/ChipDropdownInput.js.map +1 -1
- package/dist/ChipsInput/__tests__/ChipDropdownInput.test.tsx +100 -0
- package/dist/ChipsInput/__tests__/ChipInputFields.test.tsx +155 -0
- package/dist/Dropdown/BasicDropdown.cjs +0 -2
- package/dist/Dropdown/BasicDropdown.cjs.map +1 -1
- package/dist/Dropdown/BasicDropdown.js +0 -2
- package/dist/Dropdown/BasicDropdown.js.map +1 -1
- package/dist/Dropdown/DropdownButton.cjs +0 -4
- package/dist/Dropdown/DropdownButton.cjs.map +1 -1
- package/dist/Dropdown/DropdownButton.js +0 -4
- package/dist/Dropdown/DropdownButton.js.map +1 -1
- package/dist/Dropdown/DropdownContent.cjs +1 -1
- package/dist/Dropdown/DropdownContent.cjs.map +1 -1
- package/dist/Dropdown/DropdownContent.js +1 -1
- package/dist/Dropdown/DropdownContent.js.map +1 -1
- package/dist/Dropdown/DropdownFilter.cjs +0 -2
- package/dist/Dropdown/DropdownFilter.cjs.map +1 -1
- package/dist/Dropdown/DropdownFilter.js +0 -2
- package/dist/Dropdown/DropdownFilter.js.map +1 -1
- package/dist/Dropdown/__tests__/DropdownFilter.test.tsx +39 -0
- package/dist/Footer/__tests__/Footer.test.tsx +182 -0
- package/dist/GlobalNavigationBar/__tests__/Logo.test.tsx +31 -0
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs +1 -0
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs.map +1 -1
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js +1 -0
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js.map +1 -1
- package/dist/GlobalNavigationBar/desktop/SubMenu.cjs +1 -0
- package/dist/GlobalNavigationBar/desktop/SubMenu.cjs.map +1 -1
- package/dist/GlobalNavigationBar/desktop/SubMenu.js +1 -0
- package/dist/GlobalNavigationBar/desktop/SubMenu.js.map +1 -1
- package/dist/GlobalNavigationBar/desktop/__tests__/DesktopActions.test.tsx +108 -0
- package/dist/GlobalNavigationBar/desktop/__tests__/ExtendedMainMenu.test.tsx +28 -0
- package/dist/GlobalNavigationBar/desktop/__tests__/MainMenu.test.tsx +55 -0
- package/dist/GlobalNavigationBar/desktop/__tests__/RightSideNav.test.tsx +45 -0
- package/dist/GlobalNavigationBar/desktop/__tests__/UserMenu.test.tsx +125 -0
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenu.test.tsx +317 -0
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuContent.test.tsx +294 -0
- package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuHeader.test.tsx +195 -0
- package/dist/InputFields/QuickSearch.cjs +1 -1
- package/dist/InputFields/QuickSearch.cjs.map +1 -1
- package/dist/InputFields/QuickSearch.js +1 -1
- package/dist/InputFields/QuickSearch.js.map +1 -1
- package/dist/InputFields/__tests__/NumberField.test.tsx +67 -0
- package/dist/InputFields/__tests__/NumberInput.test.tsx +68 -0
- package/dist/InputFields/__tests__/QuickSearch.test.tsx +42 -0
- package/dist/LinearProgress/__tests__/LinearProgress.test.tsx +25 -0
- package/dist/List/__tests__/ListRow.test.tsx +18 -0
- package/dist/LoadingPage/__tests__/GlobalLoadingPage.test.tsx +23 -0
- package/dist/Modals/__tests__/Modal.test.tsx +169 -0
- package/dist/Modals/__tests__/ModalContainer.test.tsx +77 -0
- package/dist/Modals/__tests__/ModalContent.test.tsx +126 -0
- package/dist/NavItem/__tests__/NavItem.test.ts +6 -0
- package/dist/Navigation/NavigationProvider.cjs +43 -0
- package/dist/Navigation/NavigationProvider.cjs.map +1 -0
- package/dist/Navigation/NavigationProvider.d.ts +15 -0
- package/dist/Navigation/NavigationProvider.js +32 -0
- package/dist/Navigation/NavigationProvider.js.map +1 -0
- package/dist/Navigation/index.cjs +19 -0
- package/dist/Navigation/index.cjs.map +1 -0
- package/dist/Navigation/index.d.ts +2 -0
- package/dist/Navigation/index.js +2 -0
- package/dist/Navigation/index.js.map +1 -0
- package/dist/NotificationDot/__tests__/NotificationDot.test.tsx +33 -0
- package/dist/Paginator/__tests__/Paginator.test.tsx +33 -0
- package/dist/Popover/__tests__/Popover.test.tsx +64 -0
- package/dist/ProfileButton/__tests__/ProfileButton.test.tsx +31 -0
- package/dist/QuizButton/__tests__/QuizButton.test.tsx +53 -0
- package/dist/SegmentControl/__tests__/SegmentControl.test.tsx +145 -0
- package/dist/SideMenu/__tests__/SideMenu.test.tsx +99 -0
- package/dist/Switcher/__tests__/SwitcherMenuItem.tsx +14 -0
- package/dist/Table/Table.cjs +3 -1
- package/dist/Table/Table.cjs.map +1 -1
- package/dist/Table/Table.js +3 -1
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.cjs +1 -1
- package/dist/Table/TableBody.cjs.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableFooter.cjs +0 -2
- package/dist/Table/TableFooter.cjs.map +1 -1
- package/dist/Table/TableFooter.js +0 -2
- package/dist/Table/TableFooter.js.map +1 -1
- package/dist/Table/__tests__/Table.test.tsx +499 -0
- package/dist/Tabs/__tests__/HorizontalTabs.test.tsx +95 -0
- package/dist/Tabs/__tests__/TabLink.test.tsx +40 -0
- package/dist/Tabs/__tests__/Tablist.test.tsx +37 -0
- package/dist/Tag/__tests__/Tag.test.tsx +86 -0
- package/dist/Toasters/__tests__/Toast.test.tsx +74 -0
- package/dist/Toggles/__tests__/ToggleButton.test.tsx +53 -0
- package/dist/Toggles/__tests__/ToggleSwitch.test.tsx +87 -0
- package/dist/Tooltips/__tests__/TooltipWrapper.test.tsx +16 -0
- package/dist/icons/systemicons/CreditCard.cjs +43 -0
- package/dist/icons/systemicons/CreditCard.cjs.map +1 -0
- package/dist/icons/systemicons/CreditCard.d.ts +3 -0
- package/dist/icons/systemicons/CreditCard.js +33 -0
- package/dist/icons/systemicons/CreditCard.js.map +1 -0
- package/dist/icons/systemicons/Discount.cjs +43 -0
- package/dist/icons/systemicons/Discount.cjs.map +1 -0
- package/dist/icons/systemicons/Discount.d.ts +3 -0
- package/dist/icons/systemicons/Discount.js +33 -0
- package/dist/icons/systemicons/Discount.js.map +1 -0
- package/dist/icons/systemicons/DocumentComplete.cjs +43 -0
- package/dist/icons/systemicons/DocumentComplete.cjs.map +1 -0
- package/dist/icons/systemicons/DocumentComplete.d.ts +3 -0
- package/dist/icons/systemicons/DocumentComplete.js +33 -0
- package/dist/icons/systemicons/DocumentComplete.js.map +1 -0
- package/dist/icons/systemicons/Folder.cjs +43 -0
- package/dist/icons/systemicons/Folder.cjs.map +1 -0
- package/dist/icons/systemicons/Folder.d.ts +3 -0
- package/dist/icons/systemicons/Folder.js +33 -0
- package/dist/icons/systemicons/Folder.js.map +1 -0
- package/dist/icons/systemicons/FolderNew.cjs +43 -0
- package/dist/icons/systemicons/FolderNew.cjs.map +1 -0
- package/dist/icons/systemicons/FolderNew.d.ts +3 -0
- package/dist/icons/systemicons/FolderNew.js +33 -0
- package/dist/icons/systemicons/FolderNew.js.map +1 -0
- package/dist/icons/systemicons/MoodHappy.cjs +43 -0
- package/dist/icons/systemicons/MoodHappy.cjs.map +1 -0
- package/dist/icons/systemicons/MoodHappy.d.ts +3 -0
- package/dist/icons/systemicons/MoodHappy.js +33 -0
- package/dist/icons/systemicons/MoodHappy.js.map +1 -0
- package/dist/icons/systemicons/MoodIndifferent.cjs +43 -0
- package/dist/icons/systemicons/MoodIndifferent.cjs.map +1 -0
- package/dist/icons/systemicons/MoodIndifferent.d.ts +3 -0
- package/dist/icons/systemicons/MoodIndifferent.js +33 -0
- package/dist/icons/systemicons/MoodIndifferent.js.map +1 -0
- package/dist/icons/systemicons/MoodSad.cjs +43 -0
- package/dist/icons/systemicons/MoodSad.cjs.map +1 -0
- package/dist/icons/systemicons/MoodSad.d.ts +3 -0
- package/dist/icons/systemicons/MoodSad.js +33 -0
- package/dist/icons/systemicons/MoodSad.js.map +1 -0
- package/dist/icons/systemicons/MoodVeryHappy.cjs +43 -0
- package/dist/icons/systemicons/MoodVeryHappy.cjs.map +1 -0
- package/dist/icons/systemicons/MoodVeryHappy.d.ts +3 -0
- package/dist/icons/systemicons/MoodVeryHappy.js +33 -0
- package/dist/icons/systemicons/MoodVeryHappy.js.map +1 -0
- package/dist/icons/systemicons/MoodVerySad.cjs +43 -0
- package/dist/icons/systemicons/MoodVerySad.cjs.map +1 -0
- package/dist/icons/systemicons/MoodVerySad.d.ts +3 -0
- package/dist/icons/systemicons/MoodVerySad.js +33 -0
- package/dist/icons/systemicons/MoodVerySad.js.map +1 -0
- package/dist/icons/systemicons/Orders.cjs +43 -0
- package/dist/icons/systemicons/Orders.cjs.map +1 -0
- package/dist/icons/systemicons/Orders.d.ts +3 -0
- package/dist/icons/systemicons/Orders.js +33 -0
- package/dist/icons/systemicons/Orders.js.map +1 -0
- package/dist/icons/systemicons/Palette.cjs +43 -0
- package/dist/icons/systemicons/Palette.cjs.map +1 -0
- package/dist/icons/systemicons/Palette.d.ts +3 -0
- package/dist/icons/systemicons/Palette.js +33 -0
- package/dist/icons/systemicons/Palette.js.map +1 -0
- package/dist/icons/systemicons/Stack.cjs +43 -0
- package/dist/icons/systemicons/Stack.cjs.map +1 -0
- package/dist/icons/systemicons/Stack.d.ts +3 -0
- package/dist/icons/systemicons/Stack.js +33 -0
- package/dist/icons/systemicons/Stack.js.map +1 -0
- package/dist/styles/design-tokens/dark/tokens.css +481 -0
- package/dist/styles/design-tokens/light/tokens.css +481 -0
- package/dist/styles/design-tokens/rqi_dark/tokens.css +481 -0
- package/dist/styles/design-tokens/rqi_light/tokens.css +481 -0
- package/dist/styles/react-datepicker.css +766 -0
- package/dist/styles/typography.cjs +35 -59
- package/dist/styles/typography.cjs.map +1 -1
- package/dist/styles/typography.d.ts +1 -1
- package/dist/styles/typography.js +35 -59
- package/dist/styles/typography.js.map +1 -1
- package/dist/test-utils.cjs +16 -10
- package/dist/test-utils.cjs.map +1 -1
- package/dist/test-utils.d.ts +5 -5
- package/dist/test-utils.js +14 -8
- package/dist/test-utils.js.map +1 -1
- package/dist/utils/color-tokens.cjs +91 -0
- package/dist/utils/color-tokens.cjs.map +1 -0
- package/dist/utils/color-tokens.d.ts +19 -0
- package/dist/utils/color-tokens.js +82 -0
- package/dist/utils/color-tokens.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {render} from '../../test-utils';
|
|
3
|
+
import 'jest-styled-components';
|
|
4
|
+
import {ModalDialog} from '..';
|
|
5
|
+
import {Size, SystemIcons} from '../..';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('<ModalDialog />', () => {
|
|
10
|
+
let mountingDiv: HTMLElement;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
//being rendered as a React.Portal we need to have the 'root' div defined
|
|
14
|
+
mountingDiv = document.createElement('div');
|
|
15
|
+
mountingDiv.id = 'root';
|
|
16
|
+
document.body.appendChild(mountingDiv);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
document.body.removeChild(mountingDiv);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Check modal not rendered when isModalOpen is false', async () => {
|
|
24
|
+
const {container, getByText} = render(
|
|
25
|
+
<ModalDialog
|
|
26
|
+
key="smallModalWithoutImage"
|
|
27
|
+
title={'Header'}
|
|
28
|
+
size={Size.Small}
|
|
29
|
+
isModalOpen={false}
|
|
30
|
+
closeAction={() => {
|
|
31
|
+
}}
|
|
32
|
+
submitAction={() => {
|
|
33
|
+
}}
|
|
34
|
+
/>,
|
|
35
|
+
);
|
|
36
|
+
//check modal portal not exists when modal not opened
|
|
37
|
+
expect(container.querySelector('.ReactModalPortal')).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Check modal visible, title and footer buttons displayed correctly', async () => {
|
|
41
|
+
const {container, getByText} = render(
|
|
42
|
+
<ModalDialog
|
|
43
|
+
key="smallModalWithoutImage"
|
|
44
|
+
|
|
45
|
+
title={'Header'}
|
|
46
|
+
size={Size.Small}
|
|
47
|
+
isModalOpen={true}
|
|
48
|
+
closeAction={() => {
|
|
49
|
+
}}
|
|
50
|
+
submitAction={() => {
|
|
51
|
+
}}
|
|
52
|
+
buttons={[
|
|
53
|
+
{
|
|
54
|
+
action: () => {
|
|
55
|
+
},
|
|
56
|
+
text: 'Close',
|
|
57
|
+
variant: 'tertiary',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
action: () => {
|
|
61
|
+
},
|
|
62
|
+
text: 'Save',
|
|
63
|
+
},
|
|
64
|
+
]}
|
|
65
|
+
/>,
|
|
66
|
+
);
|
|
67
|
+
//check modal portal defined
|
|
68
|
+
expect(container.querySelector('.ReactModalPortal')).toBeDefined();
|
|
69
|
+
//Check header and footer buttons
|
|
70
|
+
expect(getByText('Header')).toBeDefined();
|
|
71
|
+
expect(getByText('Close')).toBeDefined();
|
|
72
|
+
expect(getByText('Save')).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('Check tooltip, and link displayed without right footer buttons', async () => {
|
|
76
|
+
const {baseElement, getByText} = render(
|
|
77
|
+
<ModalDialog
|
|
78
|
+
key="smallModalWithoutImage"
|
|
79
|
+
|
|
80
|
+
title={'Header'}
|
|
81
|
+
size={Size.Small}
|
|
82
|
+
isModalOpen={true}
|
|
83
|
+
closeAction={() => {
|
|
84
|
+
}}
|
|
85
|
+
submitAction={() => {
|
|
86
|
+
}}
|
|
87
|
+
tooltip={'some test tooltip'}
|
|
88
|
+
leftFooterAction={{
|
|
89
|
+
id: 'test-link',
|
|
90
|
+
actionType: 'hyperlink',
|
|
91
|
+
text: 'Link',
|
|
92
|
+
href: 'http://test.com',
|
|
93
|
+
icon: <></>,
|
|
94
|
+
variant: 'default'
|
|
95
|
+
}}
|
|
96
|
+
/>,
|
|
97
|
+
);
|
|
98
|
+
//check tooltip displayed
|
|
99
|
+
expect(getByText('some test tooltip').textContent).toBeDefined();
|
|
100
|
+
//check footer link displayed
|
|
101
|
+
expect(getByText('Link').children).toBeDefined();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('Check note and footer note displayed', async () => {
|
|
105
|
+
const {baseElement, getByText} = render(
|
|
106
|
+
<ModalDialog
|
|
107
|
+
key="smallModalWithoutImage"
|
|
108
|
+
|
|
109
|
+
title={'Header'}
|
|
110
|
+
size={Size.Small}
|
|
111
|
+
isModalOpen={true}
|
|
112
|
+
closeAction={() => {
|
|
113
|
+
}}
|
|
114
|
+
submitAction={() => {
|
|
115
|
+
}}
|
|
116
|
+
leftFooterAction={{id: 'test-note', actionType: 'note', text: 'Test note', icon: <SystemIcons.Information/>}}
|
|
117
|
+
note={'Message text'}
|
|
118
|
+
state={'critical'}
|
|
119
|
+
/>,
|
|
120
|
+
);
|
|
121
|
+
//check footer note text displayed
|
|
122
|
+
expect(getByText('Test note').textContent).toBeDefined();
|
|
123
|
+
//check note section added
|
|
124
|
+
expect(baseElement.querySelectorAll('section')?.length).toEqual(4);
|
|
125
|
+
//check note message displayed
|
|
126
|
+
expect(getByText('Message text').children).toBeDefined();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('Check back button and close icon displayed', async () => {
|
|
130
|
+
const {baseElement, getByText, container} = render(
|
|
131
|
+
<ModalDialog
|
|
132
|
+
key="smallModalWithoutImage"
|
|
133
|
+
|
|
134
|
+
title={'Header'}
|
|
135
|
+
size={Size.Small}
|
|
136
|
+
backButton={() => {
|
|
137
|
+
}}
|
|
138
|
+
isModalOpen={true}
|
|
139
|
+
closeAction={() => {
|
|
140
|
+
}}
|
|
141
|
+
submitAction={() => {
|
|
142
|
+
}}
|
|
143
|
+
/>,
|
|
144
|
+
);
|
|
145
|
+
//only 2 svg elements should be found in the header of the modal
|
|
146
|
+
expect(baseElement.querySelectorAll('svg')?.length).toEqual(2);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('Check modal body displayed', async () => {
|
|
150
|
+
const {baseElement, getByText, container} = render(
|
|
151
|
+
<ModalDialog
|
|
152
|
+
key="smallModalWithoutImage"
|
|
153
|
+
|
|
154
|
+
title={'Header'}
|
|
155
|
+
size={Size.Small}
|
|
156
|
+
isModalOpen={true}
|
|
157
|
+
closeAction={() => {
|
|
158
|
+
}}
|
|
159
|
+
submitAction={() => {
|
|
160
|
+
}}>
|
|
161
|
+
<span>Inner modal text</span>
|
|
162
|
+
</ModalDialog>,
|
|
163
|
+
);
|
|
164
|
+
//Check all dialog sections are displayed
|
|
165
|
+
expect(baseElement.querySelectorAll('section')?.length).toEqual(3);
|
|
166
|
+
//Check that the second section (modal body) has the correct text
|
|
167
|
+
expect(baseElement.querySelectorAll('section')?.[1].textContent).toEqual('Inner modal text');
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {ModalContainer} from '../index';
|
|
3
|
+
import {act, fireEvent, render} from '../../test-utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe('ModalContainer', () => {
|
|
8
|
+
|
|
9
|
+
let mountingDiv: HTMLElement;
|
|
10
|
+
const scrollToSpy = jest.fn();
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
//being rendered as a React.Portal we need to have the 'root' div defined
|
|
14
|
+
mountingDiv = document.createElement('div');
|
|
15
|
+
mountingDiv.id = 'root';
|
|
16
|
+
document.body.appendChild(mountingDiv);
|
|
17
|
+
window.scrollTo = scrollToSpy;
|
|
18
|
+
document.body.style.position = '';
|
|
19
|
+
document.body.style.left = '';
|
|
20
|
+
document.body.style.top = '';
|
|
21
|
+
document.body.style.right = '';
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
document.body.removeChild(mountingDiv);
|
|
27
|
+
scrollToSpy.mockReset();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should not render content', () => {
|
|
31
|
+
const wrapper = render(<ModalContainer showModal={false} closeModal={jest.fn()} children={'text'}/>);
|
|
32
|
+
|
|
33
|
+
expect(wrapper.queryByText('text')).not.toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should render children inside react modal', () => {
|
|
37
|
+
const wrapper = render(<ModalContainer showModal={true} closeModal={jest.fn()} children={'text'}/>);
|
|
38
|
+
|
|
39
|
+
expect(wrapper.queryByText('text')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should call onClose when react modal closes', () => {
|
|
43
|
+
const onClose = jest.fn();
|
|
44
|
+
const wrapper = render(<ModalContainer showModal={true} closeModal={onClose} children={'text'}/>);
|
|
45
|
+
|
|
46
|
+
act(() => {
|
|
47
|
+
fireEvent.click(document.querySelector('.ReactModal__Overlay')!);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(onClose).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should append custom styles when modal is mounted', () => {
|
|
54
|
+
const wrapper = render(<ModalContainer showModal={false} closeModal={jest.fn()} children={'text'}/>);
|
|
55
|
+
|
|
56
|
+
expect(document.querySelectorAll('[modal-custom-styling="active"]')).toHaveLength(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should prevent scroll when modal is open', () => {
|
|
60
|
+
Object.defineProperty(window, 'scrollY', {value: 5, writable: true});
|
|
61
|
+
|
|
62
|
+
const wrapper = render(<ModalContainer showModal={true} closeModal={jest.fn()} children={'text'}/>);
|
|
63
|
+
|
|
64
|
+
expect(document.body.style.top).toEqual('-5px');
|
|
65
|
+
expect(document.body.style.position).toEqual('fixed');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should not touch scroll if modal was not opened yet', async () => {
|
|
69
|
+
Object.defineProperty(window, 'scrollY', {value: 5, writable: true});
|
|
70
|
+
|
|
71
|
+
const wrapper = render(<ModalContainer showModal={false} closeModal={jest.fn()} children={'text'}/>);
|
|
72
|
+
|
|
73
|
+
expect(document.body.style.top).toBeFalsy();
|
|
74
|
+
expect(document.body.style.position).toBeFalsy();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../test-utils';
|
|
3
|
+
import 'jest-styled-components';
|
|
4
|
+
import { ModalContent } from '..';
|
|
5
|
+
import { Size, SystemIcons } from '../..';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('<ModalContent />', () => {
|
|
10
|
+
let mountingDiv: HTMLElement;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
//being rendered as a React.Portal we need to have the 'root' div defined
|
|
14
|
+
mountingDiv = document.createElement('div');
|
|
15
|
+
mountingDiv.id = 'root';
|
|
16
|
+
document.body.appendChild(mountingDiv);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
document.body.removeChild(mountingDiv);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Check modal not rendered when isModalOpen is false', async () => {
|
|
24
|
+
const { container, getByText } = render(
|
|
25
|
+
<ModalContent
|
|
26
|
+
key="smallModalWithoutImage"
|
|
27
|
+
title={'Header'}
|
|
28
|
+
size={Size.Small}
|
|
29
|
+
isModalOpen={false}
|
|
30
|
+
closeAction={() => {}}
|
|
31
|
+
/>,
|
|
32
|
+
);
|
|
33
|
+
//check modal portal not exists when modal not opened
|
|
34
|
+
expect(container.querySelector('.ReactModalPortal')).toBeNull();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Check modal visible, title and footer buttons displayed correctly', async () => {
|
|
38
|
+
const { container, getByText } = render(
|
|
39
|
+
<ModalContent
|
|
40
|
+
key="smallModalWithoutImage"
|
|
41
|
+
title={'Header'}
|
|
42
|
+
size={Size.Small}
|
|
43
|
+
isModalOpen={true}
|
|
44
|
+
closeAction={() => {}}
|
|
45
|
+
footerActions={[
|
|
46
|
+
{
|
|
47
|
+
action: () => {},
|
|
48
|
+
text: 'Close',
|
|
49
|
+
variant: 'tertiary',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
action: () => {},
|
|
53
|
+
text: 'Save',
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
//check modal portal defined
|
|
59
|
+
expect(container.querySelector('.ReactModalPortal')).toBeDefined();
|
|
60
|
+
//Check header and footer buttons
|
|
61
|
+
expect(getByText('Header')).toBeDefined();
|
|
62
|
+
expect(getByText('Close')).toBeDefined();
|
|
63
|
+
expect(getByText('Save')).toBeDefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Check tooltip, and link displayed without right footer buttons', async () => {
|
|
67
|
+
const { baseElement, getByText } = render(
|
|
68
|
+
<ModalContent
|
|
69
|
+
key="smallModalWithoutImage"
|
|
70
|
+
title={'Header'}
|
|
71
|
+
size={Size.Small}
|
|
72
|
+
isModalOpen={true}
|
|
73
|
+
closeAction={() => {}}
|
|
74
|
+
tooltip={'some test tooltip'}
|
|
75
|
+
leftFooterAction={{ id: 'test-link', actionType: 'hyperlink', text: 'Link', href: 'http://test.com', icon: <></>, variant: 'default' }}
|
|
76
|
+
/>,
|
|
77
|
+
);
|
|
78
|
+
//check tooltip displayed
|
|
79
|
+
expect(getByText('some test tooltip').textContent).toBeDefined();
|
|
80
|
+
//check footer link displayed
|
|
81
|
+
expect(getByText('Link').children).toBeDefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('Check note and footer note displayed', async () => {
|
|
85
|
+
const { baseElement, getByText } = render(
|
|
86
|
+
<ModalContent
|
|
87
|
+
key="smallModalWithoutImage"
|
|
88
|
+
title={'Header'}
|
|
89
|
+
size={Size.Small}
|
|
90
|
+
isModalOpen={true}
|
|
91
|
+
closeAction={() => {}}
|
|
92
|
+
leftFooterAction={{ id: 'test-note', actionType: 'note', text: 'Test note', icon: <SystemIcons.Information /> }}
|
|
93
|
+
note={'Message text'}
|
|
94
|
+
/>,
|
|
95
|
+
);
|
|
96
|
+
expect(getByText('Test note').textContent).toBeDefined();
|
|
97
|
+
expect(getByText('Message text').children).toBeDefined();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('Check close button is displayed', async () => {
|
|
101
|
+
const {getByTestId } = render(
|
|
102
|
+
<ModalContent
|
|
103
|
+
key="smallModalWithoutImage"
|
|
104
|
+
title={'Header'}
|
|
105
|
+
size={Size.Small}
|
|
106
|
+
isModalOpen={true}
|
|
107
|
+
closeAction={() => {}}
|
|
108
|
+
/>,
|
|
109
|
+
);
|
|
110
|
+
expect(getByTestId('content-modal-close-button')).toBeDefined();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('Check modal body displayed', async () => {
|
|
114
|
+
const { baseElement, getByText, container } = render(
|
|
115
|
+
<ModalContent
|
|
116
|
+
key="smallModalWithoutImage"
|
|
117
|
+
title={'Header'}
|
|
118
|
+
size={Size.Small}
|
|
119
|
+
isModalOpen={true}
|
|
120
|
+
closeAction={() => {}}>
|
|
121
|
+
<span>Inner modal text</span>
|
|
122
|
+
</ModalContent>,
|
|
123
|
+
);
|
|
124
|
+
expect(getByText('Inner modal text')).toBeDefined();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useNavigation = exports.NavigationProvider = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const NavigationContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
14
|
+
const NavigationProvider = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
navigate,
|
|
18
|
+
isActiveRoute,
|
|
19
|
+
currentPath
|
|
20
|
+
} = _ref;
|
|
21
|
+
const value = _react.default.useMemo(() => ({
|
|
22
|
+
navigate,
|
|
23
|
+
currentPath,
|
|
24
|
+
isActiveRoute
|
|
25
|
+
}), [navigate, currentPath, isActiveRoute]);
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NavigationContext.Provider, {
|
|
27
|
+
value: value,
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.NavigationProvider = NavigationProvider;
|
|
32
|
+
NavigationProvider.propTypes = {
|
|
33
|
+
children: _propTypes.default.node.isRequired
|
|
34
|
+
};
|
|
35
|
+
const useNavigation = () => {
|
|
36
|
+
const context = (0, _react.useContext)(NavigationContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error('useNavigation must be used within a NavigationProvider');
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
};
|
|
42
|
+
exports.useNavigation = useNavigation;
|
|
43
|
+
//# sourceMappingURL=NavigationProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationProvider.cjs","names":["_react","_interopRequireWildcard","require","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","NavigationContext","createContext","undefined","NavigationProvider","_ref","children","navigate","isActiveRoute","currentPath","value","React","useMemo","jsx","Provider","exports","propTypes","_propTypes","node","isRequired","useNavigation","context","useContext","Error"],"sources":["../../src/Navigation/NavigationProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\r\n\r\ninterface NavigationContextType {\r\n /** Navigate to a different path. If navigation is happening to the external source, please set 'isExternal' to true */\r\n navigate?: (path: string, isExternal: boolean) => void;\r\n /** Current path in the navigation context */\r\n currentPath?: string | undefined;\r\n /** Check if a route is active, if 'exact' flag is set then we should check for exact match, and not just part of the route */\r\n isActiveRoute?: (url: string, exact: boolean) => boolean;\r\n}\r\n\r\nconst NavigationContext = createContext<NavigationContextType | undefined>(undefined);\r\n\r\nexport interface NavigationProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\nexport const NavigationProvider: React.FC<NavigationProviderProps & Partial<NavigationContextType>> = ({ \r\n children, \r\n navigate,\r\n isActiveRoute,\r\n currentPath\r\n}) => {\r\n const value = React.useMemo(() => ({\r\n navigate,\r\n currentPath,\r\n isActiveRoute\r\n }), [navigate, currentPath, isActiveRoute]);\r\n\r\n return (\r\n <NavigationContext.Provider value={value}>\r\n {children}\r\n </NavigationContext.Provider>\r\n );\r\n};\r\n\r\nexport const useNavigation = (): NavigationContextType => {\r\n const context = useContext(NavigationContext);\r\n if (!context) {\r\n throw new Error('useNavigation must be used within a NavigationProvider');\r\n }\r\n return context;\r\n};"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAWpE,MAAMW,iBAAiB,gBAAG,IAAAC,oBAAa,EAAoCC,SAAS,CAAC;AAM9E,MAAMC,kBAAsF,GAAGC,IAAA,IAKhG;EAAA,IALiG;IACnGC,QAAQ;IACRC,QAAQ;IACRC,aAAa;IACbC;EACJ,CAAC,GAAAJ,IAAA;EACG,MAAMK,KAAK,GAAGC,cAAK,CAACC,OAAO,CAAC,OAAO;IAC/BL,QAAQ;IACRE,WAAW;IACXD;EACJ,CAAC,CAAC,EAAE,CAACD,QAAQ,EAAEE,WAAW,EAAED,aAAa,CAAC,CAAC;EAE3C,oBACI,IAAA5B,WAAA,CAAAiC,GAAA,EAACZ,iBAAiB,CAACa,QAAQ;IAACJ,KAAK,EAAEA,KAAM;IAAAJ,QAAA,EACpCA;EAAQ,CACe,CAAC;AAErC,CAAC;AAACS,OAAA,CAAAX,kBAAA,GAAAA,kBAAA;AAAAA,kBAAA,CAAAY,SAAA;EApBEV,QAAQ,EAAAW,UAAA,CAAA9B,OAAA,CAAA+B,IAAA,CAAAC;AAAA;AAsBL,MAAMC,aAAa,GAAGA,CAAA,KAA6B;EACtD,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACrB,iBAAiB,CAAC;EAC7C,IAAI,CAACoB,OAAO,EAAE;IACV,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC;EAC7E;EACA,OAAOF,OAAO;AAClB,CAAC;AAACN,OAAA,CAAAK,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface NavigationContextType {
|
|
3
|
+
/** Navigate to a different path. If navigation is happening to the external source, please set 'isExternal' to true */
|
|
4
|
+
navigate?: (path: string, isExternal: boolean) => void;
|
|
5
|
+
/** Current path in the navigation context */
|
|
6
|
+
currentPath?: string | undefined;
|
|
7
|
+
/** Check if a route is active, if 'exact' flag is set then we should check for exact match, and not just part of the route */
|
|
8
|
+
isActiveRoute?: (url: string, exact: boolean) => boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NavigationProviderProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const NavigationProvider: React.FC<NavigationProviderProps & Partial<NavigationContextType>>;
|
|
14
|
+
export declare const useNavigation: () => NavigationContextType;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _pt from "prop-types";
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const NavigationContext = /*#__PURE__*/createContext(undefined);
|
|
5
|
+
export const NavigationProvider = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
navigate,
|
|
9
|
+
isActiveRoute,
|
|
10
|
+
currentPath
|
|
11
|
+
} = _ref;
|
|
12
|
+
const value = React.useMemo(() => ({
|
|
13
|
+
navigate,
|
|
14
|
+
currentPath,
|
|
15
|
+
isActiveRoute
|
|
16
|
+
}), [navigate, currentPath, isActiveRoute]);
|
|
17
|
+
return /*#__PURE__*/_jsx(NavigationContext.Provider, {
|
|
18
|
+
value: value,
|
|
19
|
+
children: children
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
NavigationProvider.propTypes = {
|
|
23
|
+
children: _pt.node.isRequired
|
|
24
|
+
};
|
|
25
|
+
export const useNavigation = () => {
|
|
26
|
+
const context = useContext(NavigationContext);
|
|
27
|
+
if (!context) {
|
|
28
|
+
throw new Error('useNavigation must be used within a NavigationProvider');
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=NavigationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationProvider.js","names":["React","createContext","useContext","jsx","_jsx","NavigationContext","undefined","NavigationProvider","_ref","children","navigate","isActiveRoute","currentPath","value","useMemo","Provider","propTypes","_pt","node","isRequired","useNavigation","context","Error"],"sources":["../../src/Navigation/NavigationProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode } from 'react';\r\n\r\ninterface NavigationContextType {\r\n /** Navigate to a different path. If navigation is happening to the external source, please set 'isExternal' to true */\r\n navigate?: (path: string, isExternal: boolean) => void;\r\n /** Current path in the navigation context */\r\n currentPath?: string | undefined;\r\n /** Check if a route is active, if 'exact' flag is set then we should check for exact match, and not just part of the route */\r\n isActiveRoute?: (url: string, exact: boolean) => boolean;\r\n}\r\n\r\nconst NavigationContext = createContext<NavigationContextType | undefined>(undefined);\r\n\r\nexport interface NavigationProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\nexport const NavigationProvider: React.FC<NavigationProviderProps & Partial<NavigationContextType>> = ({ \r\n children, \r\n navigate,\r\n isActiveRoute,\r\n currentPath\r\n}) => {\r\n const value = React.useMemo(() => ({\r\n navigate,\r\n currentPath,\r\n isActiveRoute\r\n }), [navigate, currentPath, isActiveRoute]);\r\n\r\n return (\r\n <NavigationContext.Provider value={value}>\r\n {children}\r\n </NavigationContext.Provider>\r\n );\r\n};\r\n\r\nexport const useNavigation = (): NavigationContextType => {\r\n const context = useContext(NavigationContext);\r\n if (!context) {\r\n throw new Error('useNavigation must be used within a NavigationProvider');\r\n }\r\n return context;\r\n};"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,QAAmB,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAWpE,MAAMC,iBAAiB,gBAAGJ,aAAa,CAAoCK,SAAS,CAAC;AAMrF,OAAO,MAAMC,kBAAsF,GAAGC,IAAA,IAKhG;EAAA,IALiG;IACnGC,QAAQ;IACRC,QAAQ;IACRC,aAAa;IACbC;EACJ,CAAC,GAAAJ,IAAA;EACG,MAAMK,KAAK,GAAGb,KAAK,CAACc,OAAO,CAAC,OAAO;IAC/BJ,QAAQ;IACRE,WAAW;IACXD;EACJ,CAAC,CAAC,EAAE,CAACD,QAAQ,EAAEE,WAAW,EAAED,aAAa,CAAC,CAAC;EAE3C,oBACIP,IAAA,CAACC,iBAAiB,CAACU,QAAQ;IAACF,KAAK,EAAEA,KAAM;IAAAJ,QAAA,EACpCA;EAAQ,CACe,CAAC;AAErC,CAAC;AAACF,kBAAA,CAAAS,SAAA;EApBEP,QAAQ,EAAAQ,GAAA,CAAAC,IAAA,CAAAC;AAAA;AAsBZ,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAA6B;EACtD,MAAMC,OAAO,GAAGnB,UAAU,CAACG,iBAAiB,CAAC;EAC7C,IAAI,CAACgB,OAAO,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;EAC7E;EACA,OAAOD,OAAO;AAClB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "NavigationProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _NavigationProvider.NavigationProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useNavigation", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _NavigationProvider.useNavigation;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _NavigationProvider = require("./NavigationProvider");
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["_NavigationProvider","require"],"sources":["../../src/Navigation/index.tsx"],"sourcesContent":["export { useNavigation, NavigationProvider } from './NavigationProvider';\r\nexport type { NavigationProviderProps } from './NavigationProvider';\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useNavigation","NavigationProvider"],"sources":["../../src/Navigation/index.tsx"],"sourcesContent":["export { useNavigation, NavigationProvider } from './NavigationProvider';\r\nexport type { NavigationProviderProps } from './NavigationProvider';\r\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../test-utils';
|
|
3
|
+
import 'jest-styled-components';
|
|
4
|
+
import { NotificationDot } from '..';
|
|
5
|
+
import { Size } from '../../types';
|
|
6
|
+
import COLORS from '../../styles/colors';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('<NotificationDot />',()=>{
|
|
10
|
+
it('renders positive small notification dot', async () => {
|
|
11
|
+
const{getByTestId} = render(
|
|
12
|
+
<NotificationDot variant='positive' size={Size.Small} testId='testId'/>
|
|
13
|
+
);
|
|
14
|
+
expect(getByTestId('testId')).toHaveStyleRule('background-color',COLORS.bg_fill_positive);
|
|
15
|
+
expect(getByTestId('testId')).toHaveStyleRule('border', '2px solid ' + COLORS.bg_surface_default);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders critical large notification dot', async () => {
|
|
19
|
+
const{getByTestId} = render(
|
|
20
|
+
<NotificationDot variant='critical' size={Size.Large} testId='testId'/>
|
|
21
|
+
);
|
|
22
|
+
expect(getByTestId('testId')).toHaveStyleRule('background-color',COLORS.bg_fill_critical);
|
|
23
|
+
expect(getByTestId('testId')).toHaveStyleRule('border', '3px solid ' + COLORS.bg_surface_default);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders critical medium notification dot', async () => {
|
|
27
|
+
const{getByTestId} = render(
|
|
28
|
+
<NotificationDot variant='critical' testId='testId'/>
|
|
29
|
+
);
|
|
30
|
+
expect(getByTestId('testId')).toHaveStyleRule('background-color',COLORS.bg_fill_critical);
|
|
31
|
+
expect(getByTestId('testId')).toHaveStyleRule('border', '2px solid ' + COLORS.bg_surface_default);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { queryByAttribute, render } from '../../test-utils';
|
|
3
|
+
import { Paginator } from '../index';
|
|
4
|
+
import { createMemoryHistory } from 'history';
|
|
5
|
+
import 'jest-styled-components';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('<Paginator />', () => {
|
|
10
|
+
|
|
11
|
+
it('Renders Paginator', async () => {
|
|
12
|
+
|
|
13
|
+
let curPage = 1;
|
|
14
|
+
const { queryByText, container } = render(
|
|
15
|
+
<Paginator pageCount={6} currentPage={1} onPageChange={(page) => {
|
|
16
|
+
console.log(`Page changed to: ${page}`);
|
|
17
|
+
curPage = page; }} />
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect(queryByText('1')).toBeDefined();
|
|
21
|
+
expect(container.querySelector('#paginator-left')).toBeDefined();
|
|
22
|
+
expect(container.querySelector('#paginator-right')).toBeDefined();
|
|
23
|
+
expect(queryByText('6')).toBeDefined();
|
|
24
|
+
|
|
25
|
+
// Click on stepper to the right. Expect to be taken from 1 to 2
|
|
26
|
+
(container.querySelector('#paginator-right') as HTMLElement)?.click();
|
|
27
|
+
expect(curPage).toBe(2);
|
|
28
|
+
|
|
29
|
+
// Click directly on 6. Expect to be taken to /6
|
|
30
|
+
(queryByText('6') as HTMLElement)?.click();
|
|
31
|
+
expect(curPage).toBe(6);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../test-utils';
|
|
3
|
+
import 'jest-styled-components';
|
|
4
|
+
import { Popover } from '../..';
|
|
5
|
+
import { SystemIcons } from '../../icons';
|
|
6
|
+
import { Position } from '../../types';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('<Popover />',()=>{
|
|
10
|
+
it('renders title', async () => {
|
|
11
|
+
const{getByText, queryByTestId} = render(
|
|
12
|
+
<Popover position={Position.Bottom} topSectionProps={{text:'sample title'}} mainContent={<></>} showOnClick={false}>
|
|
13
|
+
<></>
|
|
14
|
+
</Popover>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(getByText('sample title')).toBeDefined();
|
|
18
|
+
expect(queryByTestId('closeBtn')).toBeNull();
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('renders note and title', async () => {
|
|
22
|
+
const{getByText, queryByTestId} = render(
|
|
23
|
+
<Popover position={Position.Left} topSectionProps={{text:'sample title', note:'sample note'}} mainContent={<></>} showOnClick={false}>
|
|
24
|
+
<></>
|
|
25
|
+
</Popover>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(getByText('sample title')).toBeDefined();
|
|
29
|
+
expect(getByText('sample note')).toBeDefined();
|
|
30
|
+
expect(queryByTestId('closeBtn')).toBeNull();
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('renders close button', async () => {
|
|
34
|
+
const{getByTestId} = render(
|
|
35
|
+
<Popover position={Position.Bottom} topSectionProps={{text:'sample title'}} mainContent={<></>} showOnClick={true}>
|
|
36
|
+
<></>
|
|
37
|
+
</Popover>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(getByTestId('closeBtn')).toBeDefined();
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('renders text button', async () => {
|
|
44
|
+
const{getByTestId} = render(
|
|
45
|
+
<Popover position={Position.Right} bottomSectionProps={{textButton:{label:'sample button', icon:<SystemIcons.OpenNewWindow />, action:()=>{}}}} mainContent={<></>} showOnClick={true}>
|
|
46
|
+
<></>
|
|
47
|
+
</Popover>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(getByTestId('textBtn')).toBeDefined();
|
|
51
|
+
expect(getByTestId('iconBtn').children).toHaveLength(0);
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('renders icon button', async () => {
|
|
55
|
+
const{getByTestId, queryByTestId} = render(
|
|
56
|
+
<Popover position={Position.Right} bottomSectionProps={{iconButtons:[{label:'sample button', icon:<SystemIcons.OpenNewWindow />, action:()=>{}}]}} mainContent={<></>} showOnClick={true}>
|
|
57
|
+
<></>
|
|
58
|
+
</Popover>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(queryByTestId('textBtn')).toBeNull();
|
|
62
|
+
expect(getByTestId('iconBtn').children).toHaveLength(1);
|
|
63
|
+
})
|
|
64
|
+
})
|