@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,499 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Import React libraries.
|
|
4
|
-
*/
|
|
5
|
-
import { render } from '../../test-utils';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Import custom components.
|
|
9
|
-
*/
|
|
10
|
-
import { Table } from '../index';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Import third-party libraries.
|
|
14
|
-
*/
|
|
15
|
-
import 'jest-styled-components';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Import custom types.
|
|
19
|
-
*/
|
|
20
|
-
import { TableColumn } from '../TableTypes';
|
|
21
|
-
import {StyledTableBodyRow, StyledTableFooterCollapseButton} from '../TableStyles';
|
|
22
|
-
import { act } from "react";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
describe('<Table />', () => {
|
|
27
|
-
it('Renders the Table', () => {
|
|
28
|
-
const columns: TableColumn[] = [
|
|
29
|
-
{
|
|
30
|
-
key: 'column1',
|
|
31
|
-
name: 'Column 1',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
key: 'column2',
|
|
35
|
-
name: 'Column 2',
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
-
const rows: any[] = [
|
|
39
|
-
{
|
|
40
|
-
column1: 'Test content',
|
|
41
|
-
column2: 'Test content 2',
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} title="Test title" />);
|
|
45
|
-
expect(getByTestId('TestTable')).toBeDefined();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('Table Header Row Tests', () => {
|
|
49
|
-
it('Should render table header row in case title is passed', () => {
|
|
50
|
-
const columns: TableColumn[] = [
|
|
51
|
-
{
|
|
52
|
-
key: 'column1',
|
|
53
|
-
name: 'Column 1',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
key: 'column2',
|
|
57
|
-
name: 'Column 2',
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
const rows: any[] = [
|
|
61
|
-
{
|
|
62
|
-
column1: 'Test content',
|
|
63
|
-
column2: 'Test content 2',
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} title="Test title" />);
|
|
67
|
-
expect(queryByTestId('TestTableHeaderRow')).not.toBeNull();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('Should not render table header row in case title is passed', () => {
|
|
71
|
-
const columns: TableColumn[] = [
|
|
72
|
-
{
|
|
73
|
-
key: 'column1',
|
|
74
|
-
name: 'Column 1',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
key: 'column2',
|
|
78
|
-
name: 'Column 2',
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
|
-
const rows: any[] = [
|
|
82
|
-
{
|
|
83
|
-
column1: 'Test content',
|
|
84
|
-
column2: 'Test content 2',
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
88
|
-
expect(queryByTestId('TestTableHeaderRow')).toBeNull();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('Table Header Row functional tests', () => {
|
|
92
|
-
it('Should have title', () => {
|
|
93
|
-
const columns: TableColumn[] = [
|
|
94
|
-
{
|
|
95
|
-
key: 'column1',
|
|
96
|
-
name: 'Column 1',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
key: 'column2',
|
|
100
|
-
name: 'Column 2',
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
const rows: any[] = [
|
|
104
|
-
{
|
|
105
|
-
column1: 'Test content',
|
|
106
|
-
column2: 'Test content 2',
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} title="Test Title" />);
|
|
110
|
-
const tableHeaderRow = queryByTestId('TestTableHeaderRow');
|
|
111
|
-
expect(tableHeaderRow?.children[0].children[0].textContent).toContain('Test Title');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('Should have options menu', () => {
|
|
115
|
-
const columns: TableColumn[] = [
|
|
116
|
-
{
|
|
117
|
-
key: 'column1',
|
|
118
|
-
name: 'Column 1',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
key: 'column2',
|
|
122
|
-
name: 'Column 2',
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
const rows: any[] = [
|
|
126
|
-
{
|
|
127
|
-
column1: 'Test content',
|
|
128
|
-
column2: 'Test content 2',
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} title="Test Title" />);
|
|
132
|
-
expect(queryByTestId('TestTableHeaderRow')?.getElementsByTagName('svg')).not.toBeNull();
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe('Table Column Header Row Tests', () => {
|
|
138
|
-
it('Should render column header row', () => {
|
|
139
|
-
const columns: TableColumn[] = [
|
|
140
|
-
{
|
|
141
|
-
key: 'column1',
|
|
142
|
-
name: 'Column 1',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
key: 'column2',
|
|
146
|
-
name: 'Column 2',
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
const rows: any[] = [
|
|
150
|
-
{
|
|
151
|
-
column1: 'Test content',
|
|
152
|
-
column2: 'Test content 2',
|
|
153
|
-
},
|
|
154
|
-
];
|
|
155
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
156
|
-
expect(getByTestId('TestTableColumnHeaderRow')).not.toBeNull();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('Should render two columns in the column header row', () => {
|
|
160
|
-
const columns: TableColumn[] = [
|
|
161
|
-
{
|
|
162
|
-
key: 'column1',
|
|
163
|
-
name: 'Column 1',
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
key: 'column2',
|
|
167
|
-
name: 'Column 2',
|
|
168
|
-
},
|
|
169
|
-
];
|
|
170
|
-
const rows: any[] = [
|
|
171
|
-
{
|
|
172
|
-
column1: 'Test content',
|
|
173
|
-
column2: 'Test content 2',
|
|
174
|
-
},
|
|
175
|
-
];
|
|
176
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
177
|
-
expect(getByTestId('TestTableColumnHeaderRow').children.length).toEqual(2);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('Should render correct column names in the column header row', () => {
|
|
181
|
-
const columns: TableColumn[] = [
|
|
182
|
-
{
|
|
183
|
-
key: 'column1',
|
|
184
|
-
name: 'Column 1',
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
key: 'column2',
|
|
188
|
-
name: 'Column 2',
|
|
189
|
-
},
|
|
190
|
-
];
|
|
191
|
-
const rows: any[] = [
|
|
192
|
-
{
|
|
193
|
-
column1: 'Test content',
|
|
194
|
-
column2: 'Test content 2',
|
|
195
|
-
},
|
|
196
|
-
];
|
|
197
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
198
|
-
expect(getByTestId('TestTableColumnHeaderRow').children[0].textContent).toEqual('Column 1');
|
|
199
|
-
expect(getByTestId('TestTableColumnHeaderRow').children[1].textContent).toEqual('Column 2');
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('Should render columns without no-border class in the column header row, in case title is passed', () => {
|
|
203
|
-
const columns: TableColumn[] = [
|
|
204
|
-
{
|
|
205
|
-
key: 'column1',
|
|
206
|
-
name: 'Column 1',
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
key: 'column2',
|
|
210
|
-
name: 'Column 2',
|
|
211
|
-
},
|
|
212
|
-
];
|
|
213
|
-
const rows: any[] = [
|
|
214
|
-
{
|
|
215
|
-
column1: 'Test content',
|
|
216
|
-
column2: 'Test content 2',
|
|
217
|
-
},
|
|
218
|
-
];
|
|
219
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} title="test title" />);
|
|
220
|
-
expect(getByTestId('TestTableColumnHeaderRow').children[0].classList.contains('no-border')).toBe(false);
|
|
221
|
-
expect(getByTestId('TestTableColumnHeaderRow').children[1].classList.contains('no-border')).toBe(false);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('Table Body Row tests', () => {
|
|
227
|
-
it('Should not render "No Data" row in case there are rows', () => {
|
|
228
|
-
const columns: TableColumn[] = [
|
|
229
|
-
{
|
|
230
|
-
key: 'column1',
|
|
231
|
-
name: 'Column 1',
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
key: 'column2',
|
|
235
|
-
name: 'Column 2',
|
|
236
|
-
},
|
|
237
|
-
];
|
|
238
|
-
const rows: any[] = [
|
|
239
|
-
{
|
|
240
|
-
column1: 'Test content',
|
|
241
|
-
column2: 'Test content 2',
|
|
242
|
-
},
|
|
243
|
-
];
|
|
244
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
245
|
-
expect(queryByTestId('TestTableNoDataRow')).toBeNull();
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('Should render "No Data" row in case there are no rows', () => {
|
|
249
|
-
const columns: TableColumn[] = [
|
|
250
|
-
{
|
|
251
|
-
key: 'column1',
|
|
252
|
-
name: 'Column 1',
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
key: 'column2',
|
|
256
|
-
name: 'Column 2',
|
|
257
|
-
},
|
|
258
|
-
];
|
|
259
|
-
const rows: any[] = [];
|
|
260
|
-
const { queryByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
261
|
-
expect(queryByTestId('TestTableNoDataRow')).not.toBeNull();
|
|
262
|
-
expect(queryByTestId('TestTableNoDataRow')?.textContent).toEqual('There are no rows to display');
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it('Should render a data row with correct content for each row that is passed', () => {
|
|
266
|
-
const columns: TableColumn[] = [
|
|
267
|
-
{
|
|
268
|
-
key: 'column1',
|
|
269
|
-
name: 'Column 1',
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
key: 'column2',
|
|
273
|
-
name: 'Column 2',
|
|
274
|
-
},
|
|
275
|
-
];
|
|
276
|
-
const rows: any[] = [
|
|
277
|
-
{
|
|
278
|
-
column1: 'Test content',
|
|
279
|
-
column2: 'Test content 2',
|
|
280
|
-
},
|
|
281
|
-
];
|
|
282
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
283
|
-
expect(getByTestId('TestTableDataRow')).toBeDefined();
|
|
284
|
-
expect(getByTestId('TestTableDataRow').children.length).toEqual(2);
|
|
285
|
-
expect(getByTestId('TestTableDataRow').children[0].textContent).toEqual('Test content');
|
|
286
|
-
expect(getByTestId('TestTableDataRow').children[1].textContent).toEqual('Test content 2');
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('Should render footer row', () => {
|
|
291
|
-
const columns: TableColumn[] = [
|
|
292
|
-
{
|
|
293
|
-
key: 'column1',
|
|
294
|
-
name: 'Column 1',
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
key: 'column2',
|
|
298
|
-
name: 'Column 2',
|
|
299
|
-
},
|
|
300
|
-
];
|
|
301
|
-
const rows: any[] = [
|
|
302
|
-
{
|
|
303
|
-
column1: 'Test content',
|
|
304
|
-
column2: 'Test content 2',
|
|
305
|
-
},
|
|
306
|
-
];
|
|
307
|
-
const { getByTestId } = render(<Table rows={rows} columns={columns} />);
|
|
308
|
-
expect(getByTestId('TestTableFooterRow')).toBeDefined();
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe('Table Accordion tests', () => {
|
|
312
|
-
it('Should render collapse button when configured as accordion', () => {
|
|
313
|
-
const columns: TableColumn[] = [
|
|
314
|
-
{
|
|
315
|
-
key: 'column1',
|
|
316
|
-
name: 'Column 1',
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
key: 'column2',
|
|
320
|
-
name: 'Column 2',
|
|
321
|
-
},
|
|
322
|
-
];
|
|
323
|
-
const rows: any[] = [
|
|
324
|
-
{
|
|
325
|
-
column1: 'Test content',
|
|
326
|
-
column2: 'Test content 2',
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
column1: 'Test content',
|
|
330
|
-
column2: 'Test content 2',
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
column1: 'Test content',
|
|
334
|
-
column2: 'Test content 2',
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
column1: 'Test content',
|
|
338
|
-
column2: 'Test content 2',
|
|
339
|
-
},
|
|
340
|
-
];
|
|
341
|
-
const wrapper = render(<Table rows={rows} columns={columns} accordion={true} collapsedRows={3}/>);
|
|
342
|
-
|
|
343
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableFooterCollapseButton}`)).toHaveLength(1);
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('Should not render all items when collapsed', () => {
|
|
347
|
-
const columns: TableColumn[] = [
|
|
348
|
-
{
|
|
349
|
-
key: 'column1',
|
|
350
|
-
name: 'Column 1',
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
key: 'column2',
|
|
354
|
-
name: 'Column 2',
|
|
355
|
-
},
|
|
356
|
-
];
|
|
357
|
-
const rows: any[] = [
|
|
358
|
-
{
|
|
359
|
-
column1: 'Test content',
|
|
360
|
-
column2: 'Test content 2',
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
column1: 'Test content',
|
|
364
|
-
column2: 'Test content 2',
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
column1: 'Test content',
|
|
368
|
-
column2: 'Test content 2',
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
column1: 'Test content',
|
|
372
|
-
column2: 'Test content 2',
|
|
373
|
-
},
|
|
374
|
-
];
|
|
375
|
-
const wrapper = render(<Table rows={rows} columns={columns} accordion={true} collapsedRows={3}/>);
|
|
376
|
-
|
|
377
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(3);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it('Should render all items when not collapsed', () => {
|
|
381
|
-
const columns: TableColumn[] = [
|
|
382
|
-
{
|
|
383
|
-
key: 'column1',
|
|
384
|
-
name: 'Column 1',
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
key: 'column2',
|
|
388
|
-
name: 'Column 2',
|
|
389
|
-
},
|
|
390
|
-
];
|
|
391
|
-
const rows: any[] = [
|
|
392
|
-
{
|
|
393
|
-
column1: 'Test content',
|
|
394
|
-
column2: 'Test content 2',
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
column1: 'Test content',
|
|
398
|
-
column2: 'Test content 2',
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
column1: 'Test content',
|
|
402
|
-
column2: 'Test content 2',
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
column1: 'Test content',
|
|
406
|
-
column2: 'Test content 2',
|
|
407
|
-
},
|
|
408
|
-
];
|
|
409
|
-
const wrapper = render(<Table rows={rows} columns={columns} accordion={true} collapsedRows={3}
|
|
410
|
-
collapsed={false}/>);
|
|
411
|
-
|
|
412
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(4);
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('Should expand when show more button is clicked', () => {
|
|
416
|
-
const columns: TableColumn[] = [
|
|
417
|
-
{
|
|
418
|
-
key: 'column1',
|
|
419
|
-
name: 'Column 1',
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
key: 'column2',
|
|
423
|
-
name: 'Column 2',
|
|
424
|
-
},
|
|
425
|
-
];
|
|
426
|
-
const rows: any[] = [
|
|
427
|
-
{
|
|
428
|
-
column1: 'Test content',
|
|
429
|
-
column2: 'Test content 2',
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
column1: 'Test content',
|
|
433
|
-
column2: 'Test content 2',
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
column1: 'Test content',
|
|
437
|
-
column2: 'Test content 2',
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
column1: 'Test content',
|
|
441
|
-
column2: 'Test content 2',
|
|
442
|
-
},
|
|
443
|
-
];
|
|
444
|
-
const wrapper = render(<Table rows={rows} columns={columns} accordion={true} collapsedRows={3}
|
|
445
|
-
collapsed={true}/>);
|
|
446
|
-
|
|
447
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(3);
|
|
448
|
-
|
|
449
|
-
act(() => {
|
|
450
|
-
let button = wrapper.container.querySelectorAll(`${StyledTableFooterCollapseButton}`)[0] as HTMLButtonElement;
|
|
451
|
-
button.click();
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(4);
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
it('Should collapse when show less button is clicked', () => {
|
|
458
|
-
const columns: TableColumn[] = [
|
|
459
|
-
{
|
|
460
|
-
key: 'column1',
|
|
461
|
-
name: 'Column 1',
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
key: 'column2',
|
|
465
|
-
name: 'Column 2',
|
|
466
|
-
},
|
|
467
|
-
];
|
|
468
|
-
const rows: any[] = [
|
|
469
|
-
{
|
|
470
|
-
column1: 'Test content',
|
|
471
|
-
column2: 'Test content 2',
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
column1: 'Test content',
|
|
475
|
-
column2: 'Test content 2',
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
column1: 'Test content',
|
|
479
|
-
column2: 'Test content 2',
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
column1: 'Test content',
|
|
483
|
-
column2: 'Test content 2',
|
|
484
|
-
},
|
|
485
|
-
];
|
|
486
|
-
const wrapper = render(<Table rows={rows} columns={columns} accordion={true} collapsedRows={3}
|
|
487
|
-
collapsed={false}/>);
|
|
488
|
-
|
|
489
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(4);
|
|
490
|
-
|
|
491
|
-
act(() => {
|
|
492
|
-
let button = wrapper.container.querySelectorAll(`${StyledTableFooterCollapseButton}`)[0] as HTMLButtonElement;
|
|
493
|
-
button.click();
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
expect(wrapper.container.querySelectorAll(`${StyledTableBodyRow}`)).toHaveLength(3);
|
|
497
|
-
});
|
|
498
|
-
});
|
|
499
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '../../test-utils';
|
|
3
|
-
import HorizontalTabs from '../HorizontalTabs';
|
|
4
|
-
import { Size } from '../../types';
|
|
5
|
-
import 'jest-styled-components';
|
|
6
|
-
import '@testing-library/jest-dom';
|
|
7
|
-
|
|
8
|
-
const tabs = [
|
|
9
|
-
{
|
|
10
|
-
value: 'Tab1',
|
|
11
|
-
selected: false,
|
|
12
|
-
to: 'tab1',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
value: 'Tab2',
|
|
16
|
-
selected: true,
|
|
17
|
-
to: 'tab2',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
value: 'Tab3',
|
|
21
|
-
selected: false,
|
|
22
|
-
to: 'tab3',
|
|
23
|
-
disabled: true,
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
describe('<HorizontalTabs />', () => {
|
|
31
|
-
it('Renders tabs component', async () => {
|
|
32
|
-
const { queryByTestId } = render(<HorizontalTabs size={Size.Small} tabs={tabs} onTabChange={(to) => {}}></HorizontalTabs>);
|
|
33
|
-
expect(queryByTestId('horizontal-tabs-container')).toBeTruthy();
|
|
34
|
-
expect(queryByTestId('horizontal-tabs-container')?.querySelectorAll('[data-testid*="tab_"]')).toHaveLength(3);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('Renders tabs component with side fill', async () => {
|
|
38
|
-
const { queryByTestId } = render(<HorizontalTabs size={Size.Small} sideFill={true} tabs={tabs} onTabChange={(to) => {}}></HorizontalTabs>);
|
|
39
|
-
expect(queryByTestId('horizontal-tabs-container')).toBeTruthy();
|
|
40
|
-
expect(queryByTestId('horizontal-tabs-container')?.querySelector('.fill')).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('Renders tabs component with no tabs provided', async () => {
|
|
44
|
-
const { queryByTestId } = render(<HorizontalTabs size={Size.Small} tabs={[]} onTabChange={(to) => {}}></HorizontalTabs>);
|
|
45
|
-
expect(queryByTestId('horizontal-tabs-container')).toBeTruthy();
|
|
46
|
-
expect(queryByTestId('horizontal-tabs-container')?.querySelectorAll('[data-testid*="tab_"]')).toHaveLength(0);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('Check disabled tabs rendered correctly', async () => {
|
|
50
|
-
const { queryByTestId } = render(<HorizontalTabs size={Size.Small} tabs={tabs} onTabChange={(to) => {}}></HorizontalTabs>);
|
|
51
|
-
const disabledTab = tabs.find((t) => t.disabled);
|
|
52
|
-
const notDisabledTab = tabs.find((t) => !t.disabled);
|
|
53
|
-
expect(queryByTestId('horizontal-tabs-container')).toBeTruthy();
|
|
54
|
-
|
|
55
|
-
const disabledTabElem = queryByTestId('horizontal-tabs-container')?.querySelector(`[data-testid="tab_${disabledTab?.value}"]`);
|
|
56
|
-
const notDisabledTabElem = queryByTestId('horizontal-tabs-container')?.querySelector(`[data-testid="tab_${notDisabledTab?.value}"]`);
|
|
57
|
-
|
|
58
|
-
//check disabled/non-disabled rendered
|
|
59
|
-
expect(disabledTabElem).toBeTruthy();
|
|
60
|
-
expect(notDisabledTabElem).toBeTruthy();
|
|
61
|
-
|
|
62
|
-
//check tab index prop set correct
|
|
63
|
-
expect(disabledTabElem).toHaveAttribute('tabindex', '-1');
|
|
64
|
-
expect(notDisabledTabElem).not.toHaveClass('disabled');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('Check tab change callback called on tab click', async () => {
|
|
68
|
-
const tabChangeFn = jest.fn();
|
|
69
|
-
const { queryByTestId } = render(<HorizontalTabs size={Size.Small} tabs={tabs} onTabChange={tabChangeFn}></HorizontalTabs>);
|
|
70
|
-
|
|
71
|
-
const notDisabledTab = tabs.find((t) => !t.disabled);
|
|
72
|
-
const notDisabledTabElem = queryByTestId('horizontal-tabs-container')?.querySelector(`[data-testid="tab_${notDisabledTab?.value}"]`);
|
|
73
|
-
|
|
74
|
-
//fire click tab click event
|
|
75
|
-
fireEvent(
|
|
76
|
-
notDisabledTabElem as HTMLButtonElement,
|
|
77
|
-
new MouseEvent('click', {
|
|
78
|
-
bubbles: true,
|
|
79
|
-
cancelable: true,
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
//check has been called
|
|
84
|
-
expect(tabChangeFn).toHaveBeenCalledTimes(1);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('Check tab width calculed correctly when fullWidth prop set', async () => {
|
|
88
|
-
const { queryByTestId, queryByText } = render(<HorizontalTabs fullWidth={true} size={Size.Small} tabs={tabs} onTabChange={() => {}}></HorizontalTabs>);
|
|
89
|
-
|
|
90
|
-
const tabElement = queryByTestId('horizontal-tabs-container')?.querySelector(`[data-testid="tab_Tab1"]`) as HTMLButtonElement;
|
|
91
|
-
|
|
92
|
-
expect(tabElement).toBeTruthy();
|
|
93
|
-
expect(tabElement.style).toHaveProperty('width', `${100 / tabs.length}%`);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '../../test-utils';
|
|
3
|
-
import { createMemoryHistory } from 'history';
|
|
4
|
-
import TabLink from '../TabLink';
|
|
5
|
-
import 'jest-styled-components';
|
|
6
|
-
import { COLORS } from '../../styles';
|
|
7
|
-
import { NavigationProvider } from '../../Navigation';
|
|
8
|
-
|
|
9
|
-
describe('<TabLink />', () => {
|
|
10
|
-
|
|
11
|
-
const navProps = {
|
|
12
|
-
currentPath: '',
|
|
13
|
-
isActiveRoute: () => false,
|
|
14
|
-
navigate: (path: string, isExternal: boolean) => {}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
it('Renders primary button', async () => {
|
|
18
|
-
const { queryByText, getByTestId } = render(
|
|
19
|
-
<NavigationProvider {...navProps}>
|
|
20
|
-
<TabLink requiredLine="This is a required line" onLinkClick={() => {}} href="/test" testId="TestTabLink" />
|
|
21
|
-
</NavigationProvider>,
|
|
22
|
-
);
|
|
23
|
-
expect(queryByText('This is a required line')).toBeDefined();
|
|
24
|
-
expect(getByTestId('TestTabLink')).toHaveStyle('background-color: transparent');
|
|
25
|
-
expect(getByTestId('TestTabLink')).toHaveStyle('font-size: 16px');
|
|
26
|
-
|
|
27
|
-
// Check that click takes you to correct route
|
|
28
|
-
getByTestId('TestTabLink').click();
|
|
29
|
-
//expect(history.location.pathname).toBe('/test');
|
|
30
|
-
});
|
|
31
|
-
it('Renders notification dot if defined', async () => {
|
|
32
|
-
const { queryByText, getByTestId } = render(
|
|
33
|
-
<NavigationProvider {...navProps}>
|
|
34
|
-
<TabLink requiredLine="This is a required line" onLinkClick={() => {}} href="/test" testId="TestTabLinkWithNotifcationDot" showNotificationDot={true} />
|
|
35
|
-
</NavigationProvider>,
|
|
36
|
-
);
|
|
37
|
-
expect(queryByText('This is a required line')).toBeDefined();
|
|
38
|
-
expect(getByTestId('NotificationDot')).toBeDefined();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { prettyDOM, render } from '../../test-utils';
|
|
3
|
-
import Tabs from '../Tabs';
|
|
4
|
-
import { Size } from '../../types';
|
|
5
|
-
import 'jest-styled-components';
|
|
6
|
-
import '@testing-library/jest-dom';
|
|
7
|
-
|
|
8
|
-
describe('<Tabs />', () => {
|
|
9
|
-
it('Renders tabs component', async () => {
|
|
10
|
-
const { queryByRole } = render(<Tabs size={Size.Small}></Tabs>);
|
|
11
|
-
expect(queryByRole('tablist')).toBeDefined();
|
|
12
|
-
expect(queryByRole('tablist')?.children).toHaveLength(0);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('Renders tabs component with children and medium size', async () => {
|
|
16
|
-
const renderer = render(
|
|
17
|
-
<Tabs size={Size.Medium}>
|
|
18
|
-
<a data-testid="child"><div>test tab</div><div/></a>
|
|
19
|
-
</Tabs>,
|
|
20
|
-
);
|
|
21
|
-
expect(renderer.queryByRole('tablist')).toBeTruthy();
|
|
22
|
-
expect(renderer.queryByRole('tablist')?.children).toHaveLength(1);
|
|
23
|
-
expect(renderer.queryByRole('tablist')).toHaveStyleRule('height', '56px', { modifier: 'a' });
|
|
24
|
-
expect(renderer.queryByTestId('child')?.querySelector('div')).toHaveStyle('margin: 10px 0 3px 16px');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('Renders tabs component with children and large size', async () => {
|
|
28
|
-
const { queryByRole, queryByTestId } = render(
|
|
29
|
-
<Tabs size={Size.Large}>
|
|
30
|
-
<a data-testid="child"><div>test tab</div><div/></a>
|
|
31
|
-
</Tabs>,
|
|
32
|
-
);
|
|
33
|
-
expect(queryByRole('tablist')).toBeTruthy();
|
|
34
|
-
expect(queryByRole('tablist')).toHaveStyleRule('height', '64px', { modifier: 'a' });
|
|
35
|
-
expect(queryByTestId('child')?.querySelector('div')).toHaveStyle('margin: 12px 0 4px 16px');
|
|
36
|
-
});
|
|
37
|
-
});
|