@kineticdata/react 6.0.2 → 6.0.3
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 +86 -0
- package/lib/apis/core/submissions.js +2 -2
- package/lib/components/core/form/FormForm.js +3 -2
- package/lib/components/form/FormState.js +2 -1
- package/lib/components/form/tests/Form.test.js +1432 -1194
- package/lib/components/form/tests/components.js +71 -61
- package/lib/components/table/tests/Table.redux.test.js +162 -0
- package/lib/components/table/tests/Table.test.js +767 -0
- package/lib/components/table/tests/components.js +182 -0
- package/lib/components/task/builder/TreeBuilder.js +4 -1
- package/lib/components/task/builder/builder.redux.js +25 -13
- package/lib/components/task/builder/models.js +5 -0
- package/lib/components/task/workflows/WorkflowForm.js +90 -39
- package/package.json +2 -2
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
5
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
|
|
6
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
7
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactTestRenderer = require("react-test-renderer");
|
|
10
|
+
var _index = require("../../../index");
|
|
11
|
+
var _store = require("../../../store");
|
|
12
|
+
var _immutable = require("immutable");
|
|
13
|
+
var _fixtures = require("../../../../tests/fixtures");
|
|
14
|
+
var _defaults = require("../defaults");
|
|
15
|
+
var _Table = require("../Table");
|
|
16
|
+
var _components = require("./components");
|
|
17
|
+
var _excluded = ["dataSource", "filters", "filterDataSources", "columns", "tableOptions", "tableKey", "TableView"];
|
|
18
|
+
var buildProps = function buildProps(props) {
|
|
19
|
+
props.columnComponents = (0, _Table.extractColumnComponents)(props.columns);
|
|
20
|
+
return props;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Things passed in from generateTables
|
|
24
|
+
// tableOptions, columns, dataSource, sortable
|
|
25
|
+
|
|
26
|
+
var TABLE_KEY = 'mock-table-key';
|
|
27
|
+
var mountTable = function mountTable(_ref) {
|
|
28
|
+
var dataSource = _ref.dataSource,
|
|
29
|
+
filters = _ref.filters,
|
|
30
|
+
filterDataSources = _ref.filterDataSources,
|
|
31
|
+
_ref$columns = _ref.columns,
|
|
32
|
+
columns = _ref$columns === void 0 ? [] : _ref$columns,
|
|
33
|
+
_ref$tableOptions = _ref.tableOptions,
|
|
34
|
+
tableOptions = _ref$tableOptions === void 0 ? {} : _ref$tableOptions,
|
|
35
|
+
_ref$tableKey = _ref.tableKey,
|
|
36
|
+
tableKey = _ref$tableKey === void 0 ? TABLE_KEY : _ref$tableKey,
|
|
37
|
+
_ref$TableView = _ref.TableView,
|
|
38
|
+
TableView = _ref$TableView === void 0 ? _components.TableViewMock : _ref$TableView,
|
|
39
|
+
tableProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
40
|
+
// Generate a new Table type using the options.
|
|
41
|
+
var Table = (0, _Table.generateTable)({
|
|
42
|
+
dataSource: dataSource,
|
|
43
|
+
columns: columns,
|
|
44
|
+
filters: filters,
|
|
45
|
+
filterDataSources: filterDataSources,
|
|
46
|
+
tableOptions: Object.keys(tableOptions)
|
|
47
|
+
});
|
|
48
|
+
return (0, _reactTestRenderer.act)(function () {
|
|
49
|
+
return new Promise(function (resolve) {
|
|
50
|
+
var result = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, {
|
|
51
|
+
components: _components.mockTableConfig
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement(Table, Object.assign({
|
|
53
|
+
tableKey: tableKey,
|
|
54
|
+
uncontrolled: true
|
|
55
|
+
}, tableProps, tableOptions), function (props) {
|
|
56
|
+
return /*#__PURE__*/_react["default"].createElement(TableView, props);
|
|
57
|
+
})));
|
|
58
|
+
var ready = function ready() {
|
|
59
|
+
return !(_store.store.getState().getIn(['tables', tableKey, 'loading'], true) || _store.store.getState().getIn(['tables', tableKey, 'initializing'], true));
|
|
60
|
+
};
|
|
61
|
+
if (ready()) {
|
|
62
|
+
resolve(result);
|
|
63
|
+
} else {
|
|
64
|
+
var unsub = _store.store.subscribe(function () {
|
|
65
|
+
if (ready()) {
|
|
66
|
+
resolve(result);
|
|
67
|
+
// Remove the store listener since we're done.
|
|
68
|
+
unsub();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Helper function to find an element within the rendered component
|
|
77
|
+
var getByTestId = function getByTestId(json, id) {
|
|
78
|
+
var _json$props;
|
|
79
|
+
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
80
|
+
if ((json === null || json === void 0 ? void 0 : (_json$props = json.props) === null || _json$props === void 0 ? void 0 : _json$props['data-testid']) === id) {
|
|
81
|
+
return json;
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(json === null || json === void 0 ? void 0 : json.children)) {
|
|
84
|
+
return json.children.map(function (child) {
|
|
85
|
+
return getByTestId(child, id, depth + 1);
|
|
86
|
+
}).find(Boolean);
|
|
87
|
+
}
|
|
88
|
+
if (depth === 0) {
|
|
89
|
+
throw new Error("Cannot find element with test id: '".concat(id, "'"));
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
|
|
96
|
+
* Repeat for: server-side, server-side w/client sort and paginate, client-side
|
|
97
|
+
* test sorting by column
|
|
98
|
+
* test sorting changing direction
|
|
99
|
+
* test default sort parameters
|
|
100
|
+
|
|
101
|
+
* test pure-client-side (data prop passed)
|
|
102
|
+
|
|
103
|
+
* test overriding default components for whole table
|
|
104
|
+
* test altering columns
|
|
105
|
+
** changing component
|
|
106
|
+
** What else *can* be changed???
|
|
107
|
+
* test adding columns
|
|
108
|
+
* test valueTransform
|
|
109
|
+
* test columnSet
|
|
110
|
+
* test pageSize
|
|
111
|
+
* test sortable
|
|
112
|
+
* test omit header
|
|
113
|
+
* test include footer
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
describe('<Table />', function () {
|
|
119
|
+
describe('render', function () {
|
|
120
|
+
var data, columns, wrapper, dataSourceFn;
|
|
121
|
+
beforeEach(function () {
|
|
122
|
+
data = {
|
|
123
|
+
mockData: [{
|
|
124
|
+
name: 'test',
|
|
125
|
+
status: 'active'
|
|
126
|
+
}]
|
|
127
|
+
};
|
|
128
|
+
columns = [{
|
|
129
|
+
value: 'name',
|
|
130
|
+
title: 'Name',
|
|
131
|
+
sortable: true,
|
|
132
|
+
filter: 'startsWith',
|
|
133
|
+
type: 'text'
|
|
134
|
+
}, {
|
|
135
|
+
value: 'status',
|
|
136
|
+
title: 'Status',
|
|
137
|
+
sortable: true,
|
|
138
|
+
filter: 'equals',
|
|
139
|
+
type: 'text',
|
|
140
|
+
options: function options() {
|
|
141
|
+
return [{
|
|
142
|
+
label: 'Active',
|
|
143
|
+
value: 'active'
|
|
144
|
+
}, {
|
|
145
|
+
label: 'Inactive',
|
|
146
|
+
value: 'inactive'
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
}];
|
|
150
|
+
dataSourceFn = jest.fn(function () {
|
|
151
|
+
return Promise.resolve(data);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
afterEach(function () {
|
|
155
|
+
if (wrapper) {
|
|
156
|
+
wrapper.unmount();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
test('kitchen sink', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
160
|
+
var addColumns;
|
|
161
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
162
|
+
while (1) switch (_context.prev = _context.next) {
|
|
163
|
+
case 0:
|
|
164
|
+
addColumns = [{
|
|
165
|
+
value: '_action',
|
|
166
|
+
title: 'Actions'
|
|
167
|
+
}];
|
|
168
|
+
_context.next = 3;
|
|
169
|
+
return mountTable({
|
|
170
|
+
columns: columns,
|
|
171
|
+
addColumns: addColumns,
|
|
172
|
+
dataSource: function dataSource(_tableOptions) {
|
|
173
|
+
return {
|
|
174
|
+
fn: dataSourceFn,
|
|
175
|
+
params: function params(_paramData) {
|
|
176
|
+
return [];
|
|
177
|
+
},
|
|
178
|
+
transform: function transform(result) {
|
|
179
|
+
return {
|
|
180
|
+
data: result.mockData
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
case 3:
|
|
187
|
+
wrapper = _context.sent;
|
|
188
|
+
expect(getByTestId(wrapper.toJSON(), 'TableViewMock')).toMatchSnapshot();
|
|
189
|
+
case 5:
|
|
190
|
+
case "end":
|
|
191
|
+
return _context.stop();
|
|
192
|
+
}
|
|
193
|
+
}, _callee);
|
|
194
|
+
})));
|
|
195
|
+
describe('filters', function () {
|
|
196
|
+
test('legacy filters', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
|
|
197
|
+
var filterLayout;
|
|
198
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
|
|
199
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
200
|
+
case 0:
|
|
201
|
+
_context2.next = 2;
|
|
202
|
+
return mountTable({
|
|
203
|
+
dataSource: function dataSource(_tableOptions) {
|
|
204
|
+
return {
|
|
205
|
+
fn: dataSourceFn,
|
|
206
|
+
params: function params(_paramData) {
|
|
207
|
+
return [];
|
|
208
|
+
},
|
|
209
|
+
transform: function transform(result) {
|
|
210
|
+
return {
|
|
211
|
+
data: result.mockData
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
case 2:
|
|
218
|
+
wrapper = _context2.sent;
|
|
219
|
+
filterLayout = getByTestId(wrapper.toJSON(), 'FilterLayoutMock');
|
|
220
|
+
expect(filterLayout).toBeDefined();
|
|
221
|
+
expect(filterLayout).toMatchSnapshot();
|
|
222
|
+
case 6:
|
|
223
|
+
case "end":
|
|
224
|
+
return _context2.stop();
|
|
225
|
+
}
|
|
226
|
+
}, _callee2);
|
|
227
|
+
})));
|
|
228
|
+
test('filter form', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee3() {
|
|
229
|
+
var filterForm;
|
|
230
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
|
|
231
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
232
|
+
case 0:
|
|
233
|
+
_context3.next = 2;
|
|
234
|
+
return mountTable({
|
|
235
|
+
filters: function filters() {
|
|
236
|
+
return function () {
|
|
237
|
+
return [{
|
|
238
|
+
name: 'name',
|
|
239
|
+
label: 'Name',
|
|
240
|
+
type: 'text'
|
|
241
|
+
}, {
|
|
242
|
+
name: 'status',
|
|
243
|
+
label: 'Status',
|
|
244
|
+
type: 'text'
|
|
245
|
+
}];
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
dataSource: function dataSource(_tableOptions) {
|
|
249
|
+
return {
|
|
250
|
+
fn: dataSourceFn,
|
|
251
|
+
params: function params(_paramData) {
|
|
252
|
+
return [];
|
|
253
|
+
},
|
|
254
|
+
transform: function transform(result) {
|
|
255
|
+
return {
|
|
256
|
+
data: result.mockData
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
case 2:
|
|
263
|
+
wrapper = _context3.sent;
|
|
264
|
+
filterForm = getByTestId(wrapper.toJSON(), 'FormLayoutMock');
|
|
265
|
+
expect(filterForm).toBeDefined();
|
|
266
|
+
expect(filterForm).toMatchSnapshot();
|
|
267
|
+
case 6:
|
|
268
|
+
case "end":
|
|
269
|
+
return _context3.stop();
|
|
270
|
+
}
|
|
271
|
+
}, _callee3);
|
|
272
|
+
})));
|
|
273
|
+
});
|
|
274
|
+
describe('dataSource', function () {
|
|
275
|
+
test('dataSource resolves', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee4() {
|
|
276
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context4) {
|
|
277
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
278
|
+
case 0:
|
|
279
|
+
_context4.next = 2;
|
|
280
|
+
return mountTable({
|
|
281
|
+
dataSource: function dataSource(_tableOptions) {
|
|
282
|
+
return {
|
|
283
|
+
fn: dataSourceFn,
|
|
284
|
+
params: function params(_paramData) {
|
|
285
|
+
return [];
|
|
286
|
+
},
|
|
287
|
+
transform: function transform(result) {
|
|
288
|
+
return {
|
|
289
|
+
data: result.mockData
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
case 2:
|
|
296
|
+
wrapper = _context4.sent;
|
|
297
|
+
expect(getByTestId(wrapper.toJSON(), 'TableViewMock')).toMatchSnapshot();
|
|
298
|
+
expect(dataSourceFn.mock.calls).toMatchSnapshot();
|
|
299
|
+
case 5:
|
|
300
|
+
case "end":
|
|
301
|
+
return _context4.stop();
|
|
302
|
+
}
|
|
303
|
+
}, _callee4);
|
|
304
|
+
})));
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
describe('build methods', function () {
|
|
308
|
+
var props;
|
|
309
|
+
var data = [];
|
|
310
|
+
var columns = (0, _immutable.List)([]);
|
|
311
|
+
var columnSet = (0, _immutable.List)([]);
|
|
312
|
+
var wrapper;
|
|
313
|
+
beforeEach(function () {
|
|
314
|
+
data = (0, _fixtures.users)(2);
|
|
315
|
+
columns = (0, _immutable.List)([(0, _immutable.Map)({
|
|
316
|
+
value: 'username',
|
|
317
|
+
title: 'Username'
|
|
318
|
+
})]);
|
|
319
|
+
columnSet = (0, _immutable.List)(['username']);
|
|
320
|
+
props = {
|
|
321
|
+
// Spread in the default components since the method tests will not be getting
|
|
322
|
+
// any components from the context since we're bypassing the top level `Table`
|
|
323
|
+
// component for testing.
|
|
324
|
+
components: (0, _objectSpread2["default"])({}, _defaults.DefaultTableConfig.toJS()),
|
|
325
|
+
data: data,
|
|
326
|
+
columns: columns,
|
|
327
|
+
columnSet: columnSet,
|
|
328
|
+
rows: (0, _immutable.List)(data).map(function (r) {
|
|
329
|
+
return (0, _immutable.Map)(r);
|
|
330
|
+
})
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
afterEach(function () {
|
|
334
|
+
if (wrapper) {
|
|
335
|
+
wrapper.unmount();
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
describe('#buildTable', function () {
|
|
339
|
+
test('it renders normally', function () {
|
|
340
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTable)(buildProps(props))));
|
|
341
|
+
expect(wrapper.toJSON().type).toEqual('table');
|
|
342
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-table');
|
|
343
|
+
});
|
|
344
|
+
test('it renders a custom table', function () {
|
|
345
|
+
var TableLayout = function TableLayout() {
|
|
346
|
+
return /*#__PURE__*/_react["default"].createElement("table", {
|
|
347
|
+
className: "custom-table"
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
props.components.TableLayout = TableLayout;
|
|
351
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTable)(buildProps(props))));
|
|
352
|
+
expect(wrapper.toJSON().type).toEqual('table');
|
|
353
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-table');
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
describe('#buildTableHeader', function () {
|
|
357
|
+
test('it renders normally', function () {
|
|
358
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
|
|
359
|
+
expect(wrapper.toJSON().type).toEqual('thead');
|
|
360
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-thead');
|
|
361
|
+
});
|
|
362
|
+
test('it does not render when omitHeader is set', function () {
|
|
363
|
+
props.omitHeader = true;
|
|
364
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
|
|
365
|
+
expect(wrapper.toJSON()).toBeNull();
|
|
366
|
+
});
|
|
367
|
+
test('it renders a custom thead', function () {
|
|
368
|
+
var Header = function Header() {
|
|
369
|
+
return /*#__PURE__*/_react["default"].createElement("thead", {
|
|
370
|
+
className: "custom-thead"
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
props.components.Header = Header;
|
|
374
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
|
|
375
|
+
expect(wrapper.toJSON().type).toEqual('thead');
|
|
376
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-thead');
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
describe('#buildTableHeaderRow', function () {
|
|
380
|
+
test('it renders normally', function () {
|
|
381
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderRow)(buildProps(props))));
|
|
382
|
+
expect(wrapper.toJSON().type).toEqual('tr');
|
|
383
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-tr');
|
|
384
|
+
});
|
|
385
|
+
test('it renders a custom thead', function () {
|
|
386
|
+
var HeaderRow = function HeaderRow() {
|
|
387
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
388
|
+
className: "custom-tr"
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
props.components.HeaderRow = HeaderRow;
|
|
392
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderRow)(buildProps(props))));
|
|
393
|
+
expect(wrapper.toJSON().type).toEqual('tr');
|
|
394
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-tr');
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
describe('#buildTableHeaderCell', function () {
|
|
398
|
+
test('it renders normally', function () {
|
|
399
|
+
var column = columns.first();
|
|
400
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
|
|
401
|
+
expect(wrapper.toJSON().type).toEqual('th');
|
|
402
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-th');
|
|
403
|
+
});
|
|
404
|
+
test('it renders a custom th', function () {
|
|
405
|
+
var column = columns.first();
|
|
406
|
+
var HeaderCell = function HeaderCell() {
|
|
407
|
+
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
408
|
+
className: "custom-th"
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
props.components.HeaderCell = HeaderCell;
|
|
412
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
|
|
413
|
+
expect(wrapper.toJSON().type).toEqual('th');
|
|
414
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-th');
|
|
415
|
+
});
|
|
416
|
+
test('it renders a custom th for a specific column', function () {
|
|
417
|
+
var HeaderCell = function HeaderCell() {
|
|
418
|
+
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
419
|
+
className: "custom-cell-th"
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
props.columns = props.columns.push((0, _immutable.Map)({
|
|
423
|
+
value: 'displayName',
|
|
424
|
+
title: 'DisplayName',
|
|
425
|
+
components: {
|
|
426
|
+
HeaderCell: HeaderCell
|
|
427
|
+
}
|
|
428
|
+
}));
|
|
429
|
+
props.columnSet = props.columnSet.push('displayName');
|
|
430
|
+
var column = props.columns.last();
|
|
431
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeaderCell)(buildProps(props))(column, 0)));
|
|
432
|
+
expect(wrapper.toJSON().type).toEqual('th');
|
|
433
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-cell-th');
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('#buildTableBody', function () {
|
|
437
|
+
test('it renders normally', function () {
|
|
438
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableBody)(buildProps(props))));
|
|
439
|
+
expect(wrapper.toJSON().type).toEqual('tbody');
|
|
440
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-tbody');
|
|
441
|
+
});
|
|
442
|
+
test('it renders a custom tbody', function () {
|
|
443
|
+
var Header = function Header() {
|
|
444
|
+
return /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
445
|
+
className: "custom-tbody"
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
props.components.Header = Header;
|
|
449
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableHeader)(buildProps(props))));
|
|
450
|
+
expect(wrapper.toJSON().type).toEqual('tbody');
|
|
451
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-tbody');
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
describe('#buildTableBodyRows', function () {
|
|
455
|
+
test('it renders rows normally', function () {
|
|
456
|
+
var _getByTestId, _getByTestId2, _getByTestId2$childre, _getByTestId2$childre2, _getByTestId3, _getByTestId3$childre, _getByTestId3$childre2, _getByTestId3$childre3;
|
|
457
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
458
|
+
"data-testid": "TableBodyMock"
|
|
459
|
+
}, (0, _Table.buildTableBodyRows)(buildProps(props))))));
|
|
460
|
+
expect((_getByTestId = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId === void 0 ? void 0 : _getByTestId.children).toHaveLength(props.rows.size);
|
|
461
|
+
expect((_getByTestId2 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId2 === void 0 ? void 0 : (_getByTestId2$childre = _getByTestId2.children) === null || _getByTestId2$childre === void 0 ? void 0 : (_getByTestId2$childre2 = _getByTestId2$childre[0]) === null || _getByTestId2$childre2 === void 0 ? void 0 : _getByTestId2$childre2.type).toEqual('tr');
|
|
462
|
+
expect((_getByTestId3 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId3 === void 0 ? void 0 : (_getByTestId3$childre = _getByTestId3.children) === null || _getByTestId3$childre === void 0 ? void 0 : (_getByTestId3$childre2 = _getByTestId3$childre[0]) === null || _getByTestId3$childre2 === void 0 ? void 0 : (_getByTestId3$childre3 = _getByTestId3$childre2.props) === null || _getByTestId3$childre3 === void 0 ? void 0 : _getByTestId3$childre3.className).not.toEqual('custom-tr');
|
|
463
|
+
});
|
|
464
|
+
test('it renders custom rows', function () {
|
|
465
|
+
var _getByTestId4, _getByTestId5, _getByTestId5$childre, _getByTestId5$childre2, _getByTestId6, _getByTestId6$childre, _getByTestId6$childre2, _getByTestId6$childre3;
|
|
466
|
+
var BodyRow = function BodyRow() {
|
|
467
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
468
|
+
className: "custom-tr"
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
props.components.BodyRow = BodyRow;
|
|
472
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
473
|
+
"data-testid": "TableBodyMock"
|
|
474
|
+
}, (0, _Table.buildTableBodyRows)(buildProps(props))))));
|
|
475
|
+
expect((_getByTestId4 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId4 === void 0 ? void 0 : _getByTestId4.children).toHaveLength(props.rows.size);
|
|
476
|
+
expect((_getByTestId5 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId5 === void 0 ? void 0 : (_getByTestId5$childre = _getByTestId5.children) === null || _getByTestId5$childre === void 0 ? void 0 : (_getByTestId5$childre2 = _getByTestId5$childre[0]) === null || _getByTestId5$childre2 === void 0 ? void 0 : _getByTestId5$childre2.type).toEqual('tr');
|
|
477
|
+
expect((_getByTestId6 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId6 === void 0 ? void 0 : (_getByTestId6$childre = _getByTestId6.children) === null || _getByTestId6$childre === void 0 ? void 0 : (_getByTestId6$childre2 = _getByTestId6$childre[0]) === null || _getByTestId6$childre2 === void 0 ? void 0 : (_getByTestId6$childre3 = _getByTestId6$childre2.props) === null || _getByTestId6$childre3 === void 0 ? void 0 : _getByTestId6$childre3.className).toEqual('custom-tr');
|
|
478
|
+
});
|
|
479
|
+
test('it renders default empty row', function () {
|
|
480
|
+
var _getByTestId7, _getByTestId8, _getByTestId8$childre, _getByTestId8$childre2, _getByTestId9, _getByTestId9$childre, _getByTestId9$childre2, _getByTestId9$childre3;
|
|
481
|
+
props.rows = (0, _immutable.List)([]);
|
|
482
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
483
|
+
"data-testid": "TableBodyMock"
|
|
484
|
+
}, (0, _Table.buildTableBodyRows)(buildProps(props))))));
|
|
485
|
+
expect((_getByTestId7 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId7 === void 0 ? void 0 : _getByTestId7.children).toHaveLength(1);
|
|
486
|
+
expect((_getByTestId8 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId8 === void 0 ? void 0 : (_getByTestId8$childre = _getByTestId8.children) === null || _getByTestId8$childre === void 0 ? void 0 : (_getByTestId8$childre2 = _getByTestId8$childre[0]) === null || _getByTestId8$childre2 === void 0 ? void 0 : _getByTestId8$childre2.type).toEqual('tr');
|
|
487
|
+
expect((_getByTestId9 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId9 === void 0 ? void 0 : (_getByTestId9$childre = _getByTestId9.children) === null || _getByTestId9$childre === void 0 ? void 0 : (_getByTestId9$childre2 = _getByTestId9$childre[0]) === null || _getByTestId9$childre2 === void 0 ? void 0 : (_getByTestId9$childre3 = _getByTestId9$childre2.props) === null || _getByTestId9$childre3 === void 0 ? void 0 : _getByTestId9$childre3.className).not.toEqual('custom-empty-tr');
|
|
488
|
+
});
|
|
489
|
+
test('it renders custom empty row', function () {
|
|
490
|
+
var _getByTestId10, _getByTestId11, _getByTestId11$childr, _getByTestId11$childr2, _getByTestId12, _getByTestId12$childr, _getByTestId12$childr2, _getByTestId12$childr3;
|
|
491
|
+
var EmptyBodyRow = function EmptyBodyRow() {
|
|
492
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
493
|
+
className: "custom-empty-tr"
|
|
494
|
+
});
|
|
495
|
+
};
|
|
496
|
+
props.rows = (0, _immutable.List)([]);
|
|
497
|
+
props.components.EmptyBodyRow = EmptyBodyRow;
|
|
498
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
499
|
+
"data-testid": "TableBodyMock"
|
|
500
|
+
}, (0, _Table.buildTableBodyRows)(buildProps(props))))));
|
|
501
|
+
expect((_getByTestId10 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId10 === void 0 ? void 0 : _getByTestId10.children).toHaveLength(1);
|
|
502
|
+
expect((_getByTestId11 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId11 === void 0 ? void 0 : (_getByTestId11$childr = _getByTestId11.children) === null || _getByTestId11$childr === void 0 ? void 0 : (_getByTestId11$childr2 = _getByTestId11$childr[0]) === null || _getByTestId11$childr2 === void 0 ? void 0 : _getByTestId11$childr2.type).toEqual('tr');
|
|
503
|
+
expect((_getByTestId12 = getByTestId(wrapper.toJSON(), 'TableBodyMock')) === null || _getByTestId12 === void 0 ? void 0 : (_getByTestId12$childr = _getByTestId12.children) === null || _getByTestId12$childr === void 0 ? void 0 : (_getByTestId12$childr2 = _getByTestId12$childr[0]) === null || _getByTestId12$childr2 === void 0 ? void 0 : (_getByTestId12$childr3 = _getByTestId12$childr2.props) === null || _getByTestId12$childr3 === void 0 ? void 0 : _getByTestId12$childr3.className).toEqual('custom-empty-tr');
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
describe('#buildTableBodyCells', function () {
|
|
507
|
+
test('it renders cells normally', function () {
|
|
508
|
+
var _getByTestId13, _getByTestId14, _getByTestId14$childr, _getByTestId14$childr2, _getByTestId15, _getByTestId15$childr, _getByTestId15$childr2, _getByTestId15$childr3;
|
|
509
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
510
|
+
"data-testid": "TableBodyRowMock"
|
|
511
|
+
}, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
|
|
512
|
+
expect((_getByTestId13 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId13 === void 0 ? void 0 : _getByTestId13.children).toHaveLength(props.columnSet.size);
|
|
513
|
+
expect((_getByTestId14 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId14 === void 0 ? void 0 : (_getByTestId14$childr = _getByTestId14.children) === null || _getByTestId14$childr === void 0 ? void 0 : (_getByTestId14$childr2 = _getByTestId14$childr[0]) === null || _getByTestId14$childr2 === void 0 ? void 0 : _getByTestId14$childr2.type).toEqual('td');
|
|
514
|
+
expect((_getByTestId15 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId15 === void 0 ? void 0 : (_getByTestId15$childr = _getByTestId15.children) === null || _getByTestId15$childr === void 0 ? void 0 : (_getByTestId15$childr2 = _getByTestId15$childr[0]) === null || _getByTestId15$childr2 === void 0 ? void 0 : (_getByTestId15$childr3 = _getByTestId15$childr2.props) === null || _getByTestId15$childr3 === void 0 ? void 0 : _getByTestId15$childr3.className).not.toEqual('custom-td');
|
|
515
|
+
});
|
|
516
|
+
test('it renders custom cells', function () {
|
|
517
|
+
var _getByTestId16, _getByTestId17, _getByTestId17$childr, _getByTestId17$childr2, _getByTestId18, _getByTestId18$childr, _getByTestId18$childr2, _getByTestId18$childr3;
|
|
518
|
+
var BodyCell = function BodyCell() {
|
|
519
|
+
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
520
|
+
className: "custom-td"
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
props.components.BodyCell = BodyCell;
|
|
524
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
525
|
+
"data-testid": "TableBodyRowMock"
|
|
526
|
+
}, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
|
|
527
|
+
expect((_getByTestId16 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId16 === void 0 ? void 0 : _getByTestId16.children).toHaveLength(props.columnSet.size);
|
|
528
|
+
expect((_getByTestId17 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId17 === void 0 ? void 0 : (_getByTestId17$childr = _getByTestId17.children) === null || _getByTestId17$childr === void 0 ? void 0 : (_getByTestId17$childr2 = _getByTestId17$childr[0]) === null || _getByTestId17$childr2 === void 0 ? void 0 : _getByTestId17$childr2.type).toEqual('td');
|
|
529
|
+
expect((_getByTestId18 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId18 === void 0 ? void 0 : (_getByTestId18$childr = _getByTestId18.children) === null || _getByTestId18$childr === void 0 ? void 0 : (_getByTestId18$childr2 = _getByTestId18$childr[0]) === null || _getByTestId18$childr2 === void 0 ? void 0 : (_getByTestId18$childr3 = _getByTestId18$childr2.props) === null || _getByTestId18$childr3 === void 0 ? void 0 : _getByTestId18$childr3.className).toEqual('custom-td');
|
|
530
|
+
});
|
|
531
|
+
test('it renders custom column cells', function () {
|
|
532
|
+
var _getByTestId19, _getByTestId20, _getByTestId20$childr, _getByTestId20$childr2, _getByTestId21, _getByTestId21$childr, _getByTestId21$childr2, _getByTestId21$childr3, _getByTestId22, _getByTestId22$childr, _getByTestId22$childr2, _getByTestId22$childr3;
|
|
533
|
+
var BodyCell = function BodyCell() {
|
|
534
|
+
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
535
|
+
className: "custom-td"
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
props.columns = props.columns.push((0, _immutable.Map)({
|
|
539
|
+
value: 'displayName',
|
|
540
|
+
title: 'DisplayName',
|
|
541
|
+
components: {
|
|
542
|
+
BodyCell: BodyCell
|
|
543
|
+
}
|
|
544
|
+
}));
|
|
545
|
+
props.columnSet = props.columnSet.push('displayName');
|
|
546
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
547
|
+
"data-testid": "TableBodyRowMock"
|
|
548
|
+
}, (0, _Table.buildTableBodyCells)(buildProps(props), props.rows.first(), 0))))));
|
|
549
|
+
expect((_getByTestId19 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId19 === void 0 ? void 0 : _getByTestId19.children).toHaveLength(props.columnSet.size);
|
|
550
|
+
expect((_getByTestId20 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId20 === void 0 ? void 0 : (_getByTestId20$childr = _getByTestId20.children) === null || _getByTestId20$childr === void 0 ? void 0 : (_getByTestId20$childr2 = _getByTestId20$childr[0]) === null || _getByTestId20$childr2 === void 0 ? void 0 : _getByTestId20$childr2.type).toEqual('td');
|
|
551
|
+
expect((_getByTestId21 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId21 === void 0 ? void 0 : (_getByTestId21$childr = _getByTestId21.children) === null || _getByTestId21$childr === void 0 ? void 0 : (_getByTestId21$childr2 = _getByTestId21$childr[0]) === null || _getByTestId21$childr2 === void 0 ? void 0 : (_getByTestId21$childr3 = _getByTestId21$childr2.props) === null || _getByTestId21$childr3 === void 0 ? void 0 : _getByTestId21$childr3.className).not.toEqual('custom-td');
|
|
552
|
+
expect((_getByTestId22 = getByTestId(wrapper.toJSON(), 'TableBodyRowMock')) === null || _getByTestId22 === void 0 ? void 0 : (_getByTestId22$childr = _getByTestId22.children) === null || _getByTestId22$childr === void 0 ? void 0 : (_getByTestId22$childr2 = _getByTestId22$childr[props.columnSet.size - 1]) === null || _getByTestId22$childr2 === void 0 ? void 0 : (_getByTestId22$childr3 = _getByTestId22$childr2.props) === null || _getByTestId22$childr3 === void 0 ? void 0 : _getByTestId22$childr3.className).toEqual('custom-td');
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
describe('#buildTableFooter', function () {
|
|
556
|
+
test('it does not render normally', function () {
|
|
557
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
|
|
558
|
+
expect(wrapper.toJSON()).toBeNull();
|
|
559
|
+
});
|
|
560
|
+
test('it renders with includeFooter', function () {
|
|
561
|
+
props.includeFooter = true;
|
|
562
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
|
|
563
|
+
expect(wrapper.toJSON().type).toEqual('tfoot');
|
|
564
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-tfoot');
|
|
565
|
+
});
|
|
566
|
+
test('it renders a custom tfoot', function () {
|
|
567
|
+
var Footer = function Footer() {
|
|
568
|
+
return /*#__PURE__*/_react["default"].createElement("tfoot", {
|
|
569
|
+
className: "custom-tfoot"
|
|
570
|
+
});
|
|
571
|
+
};
|
|
572
|
+
props.includeFooter = true;
|
|
573
|
+
props.components.Footer = Footer;
|
|
574
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooter)(buildProps(props))));
|
|
575
|
+
expect(wrapper.toJSON().type).toEqual('tfoot');
|
|
576
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-tfoot');
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
describe('#buildTableFooterRow', function () {
|
|
580
|
+
test('it renders normally', function () {
|
|
581
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooterRow)(buildProps(props))));
|
|
582
|
+
expect(wrapper.toJSON().type).toEqual('tr');
|
|
583
|
+
expect(wrapper.toJSON().props.className).not.toEqual('custom-tr');
|
|
584
|
+
});
|
|
585
|
+
test('it renders a custom tr', function () {
|
|
586
|
+
var FooterRow = function FooterRow() {
|
|
587
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
588
|
+
className: "custom-tr"
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
props.components.FooterRow = FooterRow;
|
|
592
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, (0, _Table.buildTableFooterRow)(buildProps(props))));
|
|
593
|
+
expect(wrapper.toJSON().type).toEqual('tr');
|
|
594
|
+
expect(wrapper.toJSON().props.className).toEqual('custom-tr');
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
describe('#buildTableFooterCells', function () {
|
|
598
|
+
test('it renders normally', function () {
|
|
599
|
+
var _getByTestId23, _getByTestId24, _getByTestId24$childr, _getByTestId24$childr2, _getByTestId25, _getByTestId25$childr, _getByTestId25$childr2, _getByTestId25$childr3;
|
|
600
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
601
|
+
"data-testid": "FooterRowMock"
|
|
602
|
+
}, (0, _Table.buildTableFooterCells)(buildProps(props))))));
|
|
603
|
+
expect((_getByTestId23 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId23 === void 0 ? void 0 : _getByTestId23.children).toHaveLength(props.columnSet.size);
|
|
604
|
+
expect((_getByTestId24 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId24 === void 0 ? void 0 : (_getByTestId24$childr = _getByTestId24.children) === null || _getByTestId24$childr === void 0 ? void 0 : (_getByTestId24$childr2 = _getByTestId24$childr[0]) === null || _getByTestId24$childr2 === void 0 ? void 0 : _getByTestId24$childr2.type).toEqual('td');
|
|
605
|
+
expect((_getByTestId25 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId25 === void 0 ? void 0 : (_getByTestId25$childr = _getByTestId25.children) === null || _getByTestId25$childr === void 0 ? void 0 : (_getByTestId25$childr2 = _getByTestId25$childr[0]) === null || _getByTestId25$childr2 === void 0 ? void 0 : (_getByTestId25$childr3 = _getByTestId25$childr2.props) === null || _getByTestId25$childr3 === void 0 ? void 0 : _getByTestId25$childr3.className).not.toEqual('custom-td');
|
|
606
|
+
});
|
|
607
|
+
test('it renders a custom td', function () {
|
|
608
|
+
var _getByTestId26, _getByTestId27, _getByTestId27$childr, _getByTestId27$childr2, _getByTestId28, _getByTestId28$childr, _getByTestId28$childr2, _getByTestId28$childr3;
|
|
609
|
+
var FooterCell = function FooterCell() {
|
|
610
|
+
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
611
|
+
className: "custom-td"
|
|
612
|
+
});
|
|
613
|
+
};
|
|
614
|
+
props.components.FooterCell = FooterCell;
|
|
615
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
616
|
+
"data-testid": "FooterRowMock"
|
|
617
|
+
}, (0, _Table.buildTableFooterCells)(buildProps(props))))));
|
|
618
|
+
expect((_getByTestId26 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId26 === void 0 ? void 0 : _getByTestId26.children).toHaveLength(props.columnSet.size);
|
|
619
|
+
expect((_getByTestId27 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId27 === void 0 ? void 0 : (_getByTestId27$childr = _getByTestId27.children) === null || _getByTestId27$childr === void 0 ? void 0 : (_getByTestId27$childr2 = _getByTestId27$childr[0]) === null || _getByTestId27$childr2 === void 0 ? void 0 : _getByTestId27$childr2.type).toEqual('td');
|
|
620
|
+
expect((_getByTestId28 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId28 === void 0 ? void 0 : (_getByTestId28$childr = _getByTestId28.children) === null || _getByTestId28$childr === void 0 ? void 0 : (_getByTestId28$childr2 = _getByTestId28$childr[0]) === null || _getByTestId28$childr2 === void 0 ? void 0 : (_getByTestId28$childr3 = _getByTestId28$childr2.props) === null || _getByTestId28$childr3 === void 0 ? void 0 : _getByTestId28$childr3.className).toEqual('custom-td');
|
|
621
|
+
});
|
|
622
|
+
test('it renders a custom td for a specific column', function () {
|
|
623
|
+
var _getByTestId29, _getByTestId30, _getByTestId30$childr, _getByTestId30$childr2, _getByTestId31, _getByTestId31$childr, _getByTestId31$childr2, _getByTestId31$childr3, _getByTestId32, _getByTestId32$childr, _getByTestId32$childr2, _getByTestId32$childr3;
|
|
624
|
+
var FooterCell = function FooterCell() {
|
|
625
|
+
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
626
|
+
className: "custom-td"
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
props.columns = props.columns.push((0, _immutable.Map)({
|
|
630
|
+
value: 'displayName',
|
|
631
|
+
title: 'DisplayName',
|
|
632
|
+
components: {
|
|
633
|
+
FooterCell: FooterCell
|
|
634
|
+
}
|
|
635
|
+
}));
|
|
636
|
+
props.columnSet = props.columnSet.push('displayName');
|
|
637
|
+
wrapper = (0, _reactTestRenderer.create)( /*#__PURE__*/_react["default"].createElement(_index.KineticLib, null, /*#__PURE__*/_react["default"].createElement("tfoot", null, /*#__PURE__*/_react["default"].createElement("tr", {
|
|
638
|
+
"data-testid": "FooterRowMock"
|
|
639
|
+
}, (0, _Table.buildTableFooterCells)(buildProps(props))))));
|
|
640
|
+
expect((_getByTestId29 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId29 === void 0 ? void 0 : _getByTestId29.children).toHaveLength(props.columnSet.size);
|
|
641
|
+
expect((_getByTestId30 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId30 === void 0 ? void 0 : (_getByTestId30$childr = _getByTestId30.children) === null || _getByTestId30$childr === void 0 ? void 0 : (_getByTestId30$childr2 = _getByTestId30$childr[0]) === null || _getByTestId30$childr2 === void 0 ? void 0 : _getByTestId30$childr2.type).toEqual('td');
|
|
642
|
+
expect((_getByTestId31 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId31 === void 0 ? void 0 : (_getByTestId31$childr = _getByTestId31.children) === null || _getByTestId31$childr === void 0 ? void 0 : (_getByTestId31$childr2 = _getByTestId31$childr[0]) === null || _getByTestId31$childr2 === void 0 ? void 0 : (_getByTestId31$childr3 = _getByTestId31$childr2.props) === null || _getByTestId31$childr3 === void 0 ? void 0 : _getByTestId31$childr3.className).not.toEqual('custom-td');
|
|
643
|
+
expect((_getByTestId32 = getByTestId(wrapper.toJSON(), 'FooterRowMock')) === null || _getByTestId32 === void 0 ? void 0 : (_getByTestId32$childr = _getByTestId32.children) === null || _getByTestId32$childr === void 0 ? void 0 : (_getByTestId32$childr2 = _getByTestId32$childr[props.columnSet.size - 1]) === null || _getByTestId32$childr2 === void 0 ? void 0 : (_getByTestId32$childr3 = _getByTestId32$childr2.props) === null || _getByTestId32$childr3 === void 0 ? void 0 : _getByTestId32$childr3.className).toEqual('custom-td');
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
describe('data manipulators', function () {
|
|
648
|
+
describe('#generateColumns', function () {
|
|
649
|
+
var columns;
|
|
650
|
+
var addColumns;
|
|
651
|
+
var alterColumns;
|
|
652
|
+
beforeEach(function () {
|
|
653
|
+
columns = [{
|
|
654
|
+
value: 'a',
|
|
655
|
+
title: 'A'
|
|
656
|
+
}];
|
|
657
|
+
addColumns = [{
|
|
658
|
+
value: 'b',
|
|
659
|
+
title: 'B'
|
|
660
|
+
}];
|
|
661
|
+
alterColumns = {};
|
|
662
|
+
});
|
|
663
|
+
test('combines the column config and additional columns', function () {
|
|
664
|
+
var total = columns.length + addColumns.length;
|
|
665
|
+
expect((0, _Table.generateColumns)(columns, addColumns, alterColumns).size).toBe(total);
|
|
666
|
+
});
|
|
667
|
+
test('alters columns with config', function () {
|
|
668
|
+
alterColumns.a = {
|
|
669
|
+
sortable: true
|
|
670
|
+
};
|
|
671
|
+
var columnConfig = (0, _Table.generateColumns)(columns, addColumns, alterColumns);
|
|
672
|
+
var column = columnConfig.find(function (c) {
|
|
673
|
+
return c.get('value') === columns[0].value;
|
|
674
|
+
});
|
|
675
|
+
expect(column.get('sortable')).toBeTruthy();
|
|
676
|
+
});
|
|
677
|
+
test('alters columns does not change value key', function () {
|
|
678
|
+
alterColumns.a = {
|
|
679
|
+
value: 'c'
|
|
680
|
+
};
|
|
681
|
+
var columnConfig = (0, _Table.generateColumns)(columns, addColumns, alterColumns);
|
|
682
|
+
var column = columnConfig.find(function (c) {
|
|
683
|
+
return c.get('value') === 'a';
|
|
684
|
+
});
|
|
685
|
+
expect(column).not.toBeUndefined();
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
describe('#sortColumns', function () {
|
|
689
|
+
test('sort columns returns expected sort order', function () {
|
|
690
|
+
var columns = (0, _immutable.List)([(0, _immutable.Map)({
|
|
691
|
+
value: 'a',
|
|
692
|
+
title: 'A'
|
|
693
|
+
}), (0, _immutable.Map)({
|
|
694
|
+
value: 'b',
|
|
695
|
+
title: 'B'
|
|
696
|
+
}), (0, _immutable.Map)({
|
|
697
|
+
value: 'c',
|
|
698
|
+
title: 'C'
|
|
699
|
+
})]);
|
|
700
|
+
var columnSet = (0, _immutable.List)(['b', 'a']);
|
|
701
|
+
expect((0, _Table.sortColumns)(columns, columnSet).toJS().map(function (c) {
|
|
702
|
+
return c.value;
|
|
703
|
+
}).join('')).toBe('bca');
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
describe('#getToggleableColumns', function () {
|
|
707
|
+
test('toggleable columns list is correct', function () {
|
|
708
|
+
var columns = (0, _immutable.List)([(0, _immutable.Map)({
|
|
709
|
+
value: 'a',
|
|
710
|
+
title: 'A',
|
|
711
|
+
toggleable: true
|
|
712
|
+
}), (0, _immutable.Map)({
|
|
713
|
+
value: 'b',
|
|
714
|
+
title: 'B'
|
|
715
|
+
}), (0, _immutable.Map)({
|
|
716
|
+
value: 'c',
|
|
717
|
+
title: 'C'
|
|
718
|
+
}), (0, _immutable.Map)({
|
|
719
|
+
value: 'd'
|
|
720
|
+
})]);
|
|
721
|
+
var columnSet = (0, _immutable.List)(['a', 'b', 'd']);
|
|
722
|
+
expect((0, _Table.getToggleableColumns)(columns, columnSet, 'table-key').toJS().map(function (c) {
|
|
723
|
+
return c.value;
|
|
724
|
+
}).join('')).toBe('ab');
|
|
725
|
+
});
|
|
726
|
+
});
|
|
727
|
+
xdescribe('#extractColumnComponents', function () {
|
|
728
|
+
var columns, addColumns, alterColumns;
|
|
729
|
+
beforeEach(function () {
|
|
730
|
+
columns = [{
|
|
731
|
+
value: 'first'
|
|
732
|
+
}, {
|
|
733
|
+
value: 'second',
|
|
734
|
+
components: {
|
|
735
|
+
BodyCell: 'two'
|
|
736
|
+
}
|
|
737
|
+
}, {
|
|
738
|
+
value: 'third'
|
|
739
|
+
}];
|
|
740
|
+
addColumns = [{
|
|
741
|
+
value: 'fourth'
|
|
742
|
+
}, {
|
|
743
|
+
value: 'fifth',
|
|
744
|
+
components: {
|
|
745
|
+
BodyCell: 'five'
|
|
746
|
+
}
|
|
747
|
+
}];
|
|
748
|
+
alterColumns = {
|
|
749
|
+
third: {
|
|
750
|
+
components: {
|
|
751
|
+
BodyCell: 'three'
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
});
|
|
756
|
+
xtest('returns a map of components with overrides', function () {
|
|
757
|
+
var result = (0, _Table.extractColumnComponents)({
|
|
758
|
+
columns: columns,
|
|
759
|
+
addColumns: addColumns,
|
|
760
|
+
alterColumns: alterColumns
|
|
761
|
+
});
|
|
762
|
+
console.log(columns);
|
|
763
|
+
expect(result.toJS()).toBe([]);
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
});
|
|
767
|
+
});
|