@patternfly/react-table 4.71.37 → 4.72.2
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/CHANGELOG.md +27 -0
- package/dist/umd/react-table.css +906 -818
- package/dist/umd/react-table.min.css +102 -14
- package/package.json +6 -6
- package/src/components/Table/{RowWrapper.test.tsx → __tests__/RowWrapper.test.tsx} +7 -5
- package/src/components/Table/__tests__/Table.test.tsx +358 -0
- package/src/components/Table/{__snapshots__ → __tests__/__snapshots__}/RowWrapper.test.tsx.snap +4 -4
- package/src/components/Table/{__snapshots__ → __tests__/__snapshots__}/Table.test.tsx.snap +2050 -1954
- package/src/components/Table/utils/__snapshots__/transformers.test.tsx.snap +0 -10
- package/src/components/Table/utils/transformers.test.tsx +37 -33
- package/src/components/Table/Table.test.tsx +0 -344
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Transformer functions expandable with parent 1`] = `
|
|
4
|
-
<ExpandableRowContent>
|
|
5
|
-
<div
|
|
6
|
-
className="pf-c-table__expandable-row-content"
|
|
7
|
-
>
|
|
8
|
-
test
|
|
9
|
-
</div>
|
|
10
|
-
</ExpandableRowContent>
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
3
|
exports[`Transformer functions selectable unselected 1`] = `
|
|
14
4
|
Object {
|
|
15
5
|
"children": <SelectColumn
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
2
5
|
import {
|
|
3
6
|
Visibility,
|
|
4
7
|
selectable,
|
|
5
8
|
sortable,
|
|
6
|
-
cellActions,
|
|
7
9
|
cellWidth,
|
|
8
10
|
collapsible,
|
|
9
11
|
scopeColTransformer,
|
|
@@ -14,9 +16,10 @@ import {
|
|
|
14
16
|
expandable,
|
|
15
17
|
expandedRow,
|
|
16
18
|
wrappable,
|
|
17
|
-
textCenter
|
|
19
|
+
textCenter,
|
|
20
|
+
cellActions
|
|
18
21
|
} from './';
|
|
19
|
-
import {
|
|
22
|
+
import { DropdownPosition, DropdownDirection } from '@patternfly/react-core';
|
|
20
23
|
import {
|
|
21
24
|
IAction,
|
|
22
25
|
IActions,
|
|
@@ -67,12 +70,9 @@ const testCellActions = ({
|
|
|
67
70
|
if (!actions || actions.length === 0) {
|
|
68
71
|
expect(returnedData.children).toBeUndefined();
|
|
69
72
|
} else {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.first()
|
|
74
|
-
.simulate('click');
|
|
75
|
-
expect(view.find('.pf-c-dropdown__menu li button')).toHaveLength(expectDisabled ? 0 : 1);
|
|
73
|
+
const { container } = render(returnedData.children as React.ReactElement<any>);
|
|
74
|
+
userEvent.click(container.querySelectorAll('.pf-c-dropdown button')[0]);
|
|
75
|
+
expect(container.querySelectorAll('.pf-c-dropdown__menu li button')).toHaveLength(expectDisabled ? 0 : 1);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
@@ -85,9 +85,11 @@ describe('Transformer functions', () => {
|
|
|
85
85
|
};
|
|
86
86
|
const returnedData = selectable('', { column, rowData: {} } as IExtra);
|
|
87
87
|
expect(returnedData).toMatchObject({ className: 'pf-c-table__check' });
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
|
|
89
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
90
|
+
|
|
91
|
+
userEvent.type(screen.getByRole('textbox'), 'a');
|
|
92
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
91
93
|
expect(onSelect.mock.results[0].value).toMatchObject({ rowId: -1, selected: false });
|
|
92
94
|
});
|
|
93
95
|
|
|
@@ -98,9 +100,11 @@ describe('Transformer functions', () => {
|
|
|
98
100
|
};
|
|
99
101
|
const returnedData = selectable('', { column, rowIndex: 0, rowData: { selected: true } } as IExtra);
|
|
100
102
|
expect(returnedData).toMatchObject({ className: 'pf-c-table__check' });
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
|
|
104
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
105
|
+
|
|
106
|
+
userEvent.type(screen.getByRole('textbox'), 'a');
|
|
107
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
104
108
|
expect(onSelect.mock.results[0].value).toMatchObject({ rowId: 0, selected: false });
|
|
105
109
|
});
|
|
106
110
|
|
|
@@ -111,10 +115,6 @@ describe('Transformer functions', () => {
|
|
|
111
115
|
};
|
|
112
116
|
const returnedData = selectable('', { column, rowIndex: 0, rowData: { selected: false } } as IExtra);
|
|
113
117
|
expect(returnedData).toMatchSnapshot();
|
|
114
|
-
const view = mount(returnedData.children as React.ReactElement<any>);
|
|
115
|
-
view.find('input').simulate('change');
|
|
116
|
-
expect(onSelect.mock.calls).toHaveLength(1);
|
|
117
|
-
expect(onSelect.mock.results[0].value).toMatchObject({ rowId: 0, selected: true });
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
|
|
@@ -124,8 +124,9 @@ describe('Transformer functions', () => {
|
|
|
124
124
|
const column = { extraParams: { sortBy: {}, onSort } };
|
|
125
125
|
const returnedData = sortable('', { column, columnIndex: 0 });
|
|
126
126
|
expect(returnedData).toMatchObject({ className: 'pf-c-table__sort' });
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
|
|
128
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
129
|
+
userEvent.click(screen.getByRole('button'));
|
|
129
130
|
expect(onSort.mock.calls).toHaveLength(1);
|
|
130
131
|
});
|
|
131
132
|
|
|
@@ -134,8 +135,9 @@ describe('Transformer functions', () => {
|
|
|
134
135
|
const column = { extraParams: { sortBy: { index: 0, direction: 'asc' }, onSort } };
|
|
135
136
|
const returnedData = sortable('', { column, columnIndex: 0 } as IExtra);
|
|
136
137
|
expect(returnedData).toMatchSnapshot();
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
|
|
139
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
140
|
+
userEvent.click(screen.getByRole('button'));
|
|
139
141
|
expect(onSort.mock.calls).toHaveLength(1);
|
|
140
142
|
});
|
|
141
143
|
|
|
@@ -144,8 +146,9 @@ describe('Transformer functions', () => {
|
|
|
144
146
|
const column = { extraParams: { sortBy: { index: 0, direction: 'desc' }, onSort } };
|
|
145
147
|
const returnedData = sortable('', { column, columnIndex: 0 } as IExtra);
|
|
146
148
|
expect(returnedData).toMatchObject({ className: 'pf-c-table__sort pf-m-selected' });
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
|
|
150
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
151
|
+
userEvent.click(screen.getByRole('button'));
|
|
149
152
|
expect(onSort.mock.calls).toHaveLength(1);
|
|
150
153
|
});
|
|
151
154
|
});
|
|
@@ -213,8 +216,9 @@ describe('Transformer functions', () => {
|
|
|
213
216
|
};
|
|
214
217
|
const returnedData = collapsible('', { rowIndex: 0, rowData, column });
|
|
215
218
|
expect(returnedData).toMatchObject({ className: 'pf-c-table__toggle' });
|
|
216
|
-
|
|
217
|
-
|
|
219
|
+
|
|
220
|
+
render(returnedData.children as React.ReactElement<any>);
|
|
221
|
+
userEvent.click(screen.getByRole('button'));
|
|
218
222
|
expect(onCollapse.mock.calls).toHaveLength(1);
|
|
219
223
|
});
|
|
220
224
|
|
|
@@ -237,9 +241,8 @@ describe('Transformer functions', () => {
|
|
|
237
241
|
rowData: { parent: 1 },
|
|
238
242
|
column: { extraParams: {} }
|
|
239
243
|
} as IExtra);
|
|
240
|
-
|
|
241
|
-
expect(
|
|
242
|
-
expect(view).toMatchSnapshot();
|
|
244
|
+
render(returned as React.ReactElement<any>);
|
|
245
|
+
expect(screen.getByText('test').parentElement).toBeInTheDocument();
|
|
243
246
|
});
|
|
244
247
|
|
|
245
248
|
test('no parent', () => {
|
|
@@ -284,8 +287,9 @@ describe('Transformer functions', () => {
|
|
|
284
287
|
test('headerCol', () => {
|
|
285
288
|
const returned = headerCol('some-id')('value', { rowIndex: 0 });
|
|
286
289
|
expect(returned).toMatchObject({ component: 'th' });
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
|
|
291
|
+
render(returned.children as React.ReactElement<any>);
|
|
292
|
+
expect(screen.getByText('value')).toBeInTheDocument();
|
|
289
293
|
});
|
|
290
294
|
|
|
291
295
|
test('emptyCol', () => {
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { mount } from 'enzyme';
|
|
4
|
-
import {
|
|
5
|
-
Table,
|
|
6
|
-
TableHeader,
|
|
7
|
-
TableBody,
|
|
8
|
-
TableGridBreakpoint,
|
|
9
|
-
TableVariant,
|
|
10
|
-
RowSelectVariant,
|
|
11
|
-
cellWidth,
|
|
12
|
-
headerCol,
|
|
13
|
-
sortable,
|
|
14
|
-
expandable,
|
|
15
|
-
compoundExpand,
|
|
16
|
-
IRow,
|
|
17
|
-
OnCollapse,
|
|
18
|
-
OnExpand,
|
|
19
|
-
OnSelect,
|
|
20
|
-
OnRowEdit,
|
|
21
|
-
OnSort,
|
|
22
|
-
wrappable,
|
|
23
|
-
nowrap,
|
|
24
|
-
truncate,
|
|
25
|
-
breakWord,
|
|
26
|
-
fitContent,
|
|
27
|
-
ICell
|
|
28
|
-
} from './index';
|
|
29
|
-
import { rows, columns, editableRows, editableColumns, actions } from '../../test-helpers/data-sets';
|
|
30
|
-
import { ColumnsType } from './base';
|
|
31
|
-
|
|
32
|
-
describe('Simple table', () => {
|
|
33
|
-
test('caption', () => {
|
|
34
|
-
const view = render(
|
|
35
|
-
<Table caption="Simple Table" cells={columns} rows={rows}>
|
|
36
|
-
<TableHeader />
|
|
37
|
-
<TableBody />
|
|
38
|
-
</Table>
|
|
39
|
-
);
|
|
40
|
-
expect(view.container).toMatchSnapshot();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('header', () => {
|
|
44
|
-
const view = render(
|
|
45
|
-
<Table header={<h4>Header title</h4>} cells={columns} rows={rows}>
|
|
46
|
-
<TableHeader />
|
|
47
|
-
<TableBody />
|
|
48
|
-
</Table>
|
|
49
|
-
);
|
|
50
|
-
expect(view.container).toMatchSnapshot();
|
|
51
|
-
});
|
|
52
|
-
test('aria-label', () => {
|
|
53
|
-
const view = render(
|
|
54
|
-
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
55
|
-
<TableHeader />
|
|
56
|
-
<TableBody />
|
|
57
|
-
</Table>
|
|
58
|
-
);
|
|
59
|
-
expect(view.container).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('Editable table', () => {
|
|
64
|
-
const onRowEdit: OnRowEdit = () => undefined;
|
|
65
|
-
const view = render(
|
|
66
|
-
<Table caption="Editable Table" cells={editableColumns} rows={editableRows} onRowEdit={onRowEdit}>
|
|
67
|
-
<TableHeader />
|
|
68
|
-
<TableBody />
|
|
69
|
-
</Table>
|
|
70
|
-
);
|
|
71
|
-
expect(view.container).toMatchSnapshot();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('Sortable table', () => {
|
|
75
|
-
const onSortCall: OnSort = () => undefined;
|
|
76
|
-
columns[0] = { ...(columns[0] as object), transforms: [sortable] };
|
|
77
|
-
const view = render(
|
|
78
|
-
<Table aria-label="Aria labeled" onSort={onSortCall} sortBy={{}} cells={columns} rows={rows}>
|
|
79
|
-
<TableHeader />
|
|
80
|
-
<TableBody />
|
|
81
|
-
</Table>
|
|
82
|
-
);
|
|
83
|
-
expect(view.container).toMatchSnapshot();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('Row click table', () => {
|
|
87
|
-
const rowClickHandler = jest.fn();
|
|
88
|
-
const view = render(
|
|
89
|
-
<Table aria-label="Row click table" cells={columns} rows={rows}>
|
|
90
|
-
<TableHeader />
|
|
91
|
-
<TableBody onRowClick={rowClickHandler} />
|
|
92
|
-
</Table>
|
|
93
|
-
);
|
|
94
|
-
expect(view.container).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe('Table variants', () => {
|
|
98
|
-
Object.values(TableGridBreakpoint).forEach(oneBreakpoint => {
|
|
99
|
-
test(`Breakpoint - ${oneBreakpoint}`, () => {
|
|
100
|
-
const view = render(
|
|
101
|
-
<Table aria-label="Aria labeled" gridBreakPoint={oneBreakpoint} cells={columns} rows={rows}>
|
|
102
|
-
<TableHeader />
|
|
103
|
-
<TableBody />
|
|
104
|
-
</Table>
|
|
105
|
-
);
|
|
106
|
-
expect(view.container).toMatchSnapshot();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
Object.values(TableVariant).forEach(onevariant => {
|
|
110
|
-
test(`Size - ${onevariant}`, () => {
|
|
111
|
-
const view = render(
|
|
112
|
-
<Table aria-label="Aria labeled" variant={onevariant} cells={columns} rows={rows}>
|
|
113
|
-
<TableHeader />
|
|
114
|
-
<TableBody />
|
|
115
|
-
</Table>
|
|
116
|
-
);
|
|
117
|
-
expect(view.container).toMatchSnapshot();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('Simple Actions table', () => {
|
|
123
|
-
const rowsWithDisabledAction = [
|
|
124
|
-
...rows,
|
|
125
|
-
{
|
|
126
|
-
cells: ['one', 'two', 'three', 'four', 'five'],
|
|
127
|
-
disableActions: true
|
|
128
|
-
}
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
const view = render(
|
|
132
|
-
<Table aria-label="Aria labeled" actions={actions} cells={columns} rows={rowsWithDisabledAction}>
|
|
133
|
-
<TableHeader />
|
|
134
|
-
<TableBody />
|
|
135
|
-
</Table>
|
|
136
|
-
);
|
|
137
|
-
expect(view.container).toMatchSnapshot();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
test('Actions table', () => {
|
|
141
|
-
const view = render(
|
|
142
|
-
<Table
|
|
143
|
-
aria-label="Aria labeled"
|
|
144
|
-
actionResolver={() => actions}
|
|
145
|
-
areActionsDisabled={() => false}
|
|
146
|
-
cells={columns}
|
|
147
|
-
rows={rows}
|
|
148
|
-
>
|
|
149
|
-
<TableHeader />
|
|
150
|
-
<TableBody />
|
|
151
|
-
</Table>
|
|
152
|
-
);
|
|
153
|
-
expect(view.container).toMatchSnapshot();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
test('Cell header table', () => {
|
|
157
|
-
columns[0] = { ...(columns[0] as object), cellTransforms: [headerCol('test-headercol-')] };
|
|
158
|
-
const view = render(
|
|
159
|
-
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
160
|
-
<TableHeader />
|
|
161
|
-
<TableBody />
|
|
162
|
-
</Table>
|
|
163
|
-
);
|
|
164
|
-
expect(view.container).toMatchSnapshot();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test('Collapsible table', () => {
|
|
168
|
-
rows[0] = { ...rows[0], isOpen: true };
|
|
169
|
-
rows[1] = { ...rows[1], parent: 0 };
|
|
170
|
-
rows[3] = { ...rows[3], isOpen: false };
|
|
171
|
-
rows[4] = { ...rows[4], parent: 3 };
|
|
172
|
-
columns[0] = { ...(columns[0] as object), cellFormatters: [expandable] };
|
|
173
|
-
const onCollapse: OnCollapse = () => undefined;
|
|
174
|
-
const view = render(
|
|
175
|
-
<Table aria-label="Aria labeled" onCollapse={onCollapse} cells={columns} rows={rows}>
|
|
176
|
-
<TableHeader />
|
|
177
|
-
<TableBody />
|
|
178
|
-
</Table>
|
|
179
|
-
);
|
|
180
|
-
expect(view.container).toMatchSnapshot();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('Compound Expandable table', () => {
|
|
184
|
-
const compoundColumns: ColumnsType = [
|
|
185
|
-
{ title: 'col1', cellTransforms: [compoundExpand] },
|
|
186
|
-
{ title: 'col2', cellTransforms: [compoundExpand] }
|
|
187
|
-
];
|
|
188
|
-
const compoundRows: IRow[] = [
|
|
189
|
-
{
|
|
190
|
-
isOpen: true,
|
|
191
|
-
cells: [
|
|
192
|
-
{ title: '1', props: { isOpen: true } },
|
|
193
|
-
{ title: '2', props: { isOpen: false } }
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
{ parent: 0, compoundParent: 0, cells: [{ title: 'expanded', props: { colSpan: 2 } }] },
|
|
197
|
-
{
|
|
198
|
-
isOpen: false,
|
|
199
|
-
cells: [
|
|
200
|
-
{ title: '3', props: { isOpen: false } },
|
|
201
|
-
{ title: '4', props: { isOpen: false } }
|
|
202
|
-
]
|
|
203
|
-
},
|
|
204
|
-
{ parent: 2, compoundParent: 0, cells: [{ title: 'expanded', props: { colSpan: 2 } }] }
|
|
205
|
-
];
|
|
206
|
-
const onExpand: OnExpand = () => undefined;
|
|
207
|
-
const view = render(
|
|
208
|
-
<Table aria-label="Aria labeled" onExpand={onExpand} cells={compoundColumns} rows={compoundRows}>
|
|
209
|
-
<TableHeader />
|
|
210
|
-
<TableBody />
|
|
211
|
-
</Table>
|
|
212
|
-
);
|
|
213
|
-
expect(view.container).toMatchSnapshot();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test('Collapsible nested table', () => {
|
|
217
|
-
rows[0] = { ...rows[0], isOpen: false };
|
|
218
|
-
rows[1] = { ...rows[1], parent: 0, isOpen: true };
|
|
219
|
-
rows[2] = { ...rows[2], parent: 1 };
|
|
220
|
-
const onCollapse: OnCollapse = () => undefined;
|
|
221
|
-
const view = render(
|
|
222
|
-
<Table aria-label="Aria labeled" onCollapse={onCollapse} cells={columns} rows={rows}>
|
|
223
|
-
<TableHeader />
|
|
224
|
-
<TableBody />
|
|
225
|
-
</Table>
|
|
226
|
-
);
|
|
227
|
-
expect(view.container).toMatchSnapshot();
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
test('Selectable table', () => {
|
|
231
|
-
const onSelect: OnSelect = () => undefined;
|
|
232
|
-
const view = render(
|
|
233
|
-
<Table aria-label="Aria labeled" onSelect={onSelect} cells={columns} rows={rows}>
|
|
234
|
-
<TableHeader />
|
|
235
|
-
<TableBody />
|
|
236
|
-
</Table>
|
|
237
|
-
);
|
|
238
|
-
expect(view.container).toMatchSnapshot();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
test('Selectable table with Radio', () => {
|
|
242
|
-
const onSelect: OnSelect = () => undefined;
|
|
243
|
-
const view = render(
|
|
244
|
-
<Table
|
|
245
|
-
aria-label="Aria labeled"
|
|
246
|
-
selectVariant={RowSelectVariant.radio}
|
|
247
|
-
onSelect={onSelect}
|
|
248
|
-
cells={columns}
|
|
249
|
-
rows={rows}
|
|
250
|
-
>
|
|
251
|
-
<TableHeader />
|
|
252
|
-
<TableBody />
|
|
253
|
-
</Table>
|
|
254
|
-
);
|
|
255
|
-
expect(view.container).toMatchSnapshot();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
test('Control text table', () => {
|
|
259
|
-
const controlTextColumns: ICell[] = [
|
|
260
|
-
{ ...(columns[0] as object), transforms: [nowrap] },
|
|
261
|
-
{ title: 'new object column', transforms: [wrappable] },
|
|
262
|
-
{ ...(columns[2] as object), transforms: [breakWord] },
|
|
263
|
-
{ title: 'new object column', transforms: [truncate] },
|
|
264
|
-
{ ...(columns[4] as object), transforms: [fitContent] }
|
|
265
|
-
];
|
|
266
|
-
|
|
267
|
-
const view = render(
|
|
268
|
-
<Table aria-label="Aria labeled" cells={controlTextColumns} rows={rows}>
|
|
269
|
-
<TableHeader />
|
|
270
|
-
<TableBody />
|
|
271
|
-
</Table>
|
|
272
|
-
);
|
|
273
|
-
expect(view.container).toMatchSnapshot();
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
test('Header width table', () => {
|
|
277
|
-
columns[0] = { ...(columns[0] as object), transforms: [cellWidth(10)] };
|
|
278
|
-
columns[2] = { ...(columns[2] as object), transforms: [cellWidth(30)] };
|
|
279
|
-
columns[4] = { ...(columns[4] as object), transforms: [cellWidth(100)] };
|
|
280
|
-
const view = render(
|
|
281
|
-
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
282
|
-
<TableHeader />
|
|
283
|
-
<TableBody />
|
|
284
|
-
</Table>
|
|
285
|
-
);
|
|
286
|
-
expect(view.container).toMatchSnapshot();
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
test('Selectable table with selected expandable row', () => {
|
|
290
|
-
const data = {
|
|
291
|
-
cells: ['column'],
|
|
292
|
-
rows: [
|
|
293
|
-
{
|
|
294
|
-
cells: ['one'],
|
|
295
|
-
selected: true
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
cells: ['one'],
|
|
299
|
-
parent: 0
|
|
300
|
-
}
|
|
301
|
-
],
|
|
302
|
-
onSelect: (e: React.FormEvent<HTMLInputElement>) => e
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
const view = mount(
|
|
306
|
-
<Table aria-label="Aria labeled" {...data}>
|
|
307
|
-
<TableHeader />
|
|
308
|
-
<TableBody />
|
|
309
|
-
</Table>
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
expect(view.find('input[name="check-all"]').prop('checked')).toEqual(true);
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
test('Empty state table', () => {
|
|
316
|
-
const data = {
|
|
317
|
-
cells: ['Hostname', 'IP address', 'Role', 'Team'],
|
|
318
|
-
rows: [
|
|
319
|
-
{
|
|
320
|
-
heightAuto: true,
|
|
321
|
-
cells: [
|
|
322
|
-
{
|
|
323
|
-
title: <div>Empty State Component</div>,
|
|
324
|
-
props: { colSpan: 8 }
|
|
325
|
-
}
|
|
326
|
-
]
|
|
327
|
-
}
|
|
328
|
-
]
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
const view = mount(
|
|
332
|
-
<Table aria-label="Aria labeled" {...data}>
|
|
333
|
-
<TableHeader />
|
|
334
|
-
<TableBody />
|
|
335
|
-
</Table>
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
expect(
|
|
339
|
-
view
|
|
340
|
-
.find('tbody')
|
|
341
|
-
.find('td')
|
|
342
|
-
.prop('colSpan')
|
|
343
|
-
).toEqual(8);
|
|
344
|
-
});
|