Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@buffetjs/core/build/esm/components/Table/tests/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React from 'react';
import { mount } from 'enzyme';
import { TableRowEmpty } from '@buffetjs/styles';
import TableRow from '../../TableRow';
import Table from '../index';
import ActionCollapse from '../ActionCollapse';
describe('<Table />', function () {
// eslint-disable-next-line jest/expect-expect
it('Should not crash', function () {
mount( /*#__PURE__*/React.createElement(Table, null));
});
it('Should display the Empty row if there is no data', function () {
var wrapper = mount( /*#__PURE__*/React.createElement(Table, null));
expect(wrapper.find(TableRow)).toHaveLength(0);
expect(wrapper.find(TableRowEmpty)).toHaveLength(1);
});
it('Should display a custom component if given', function () {
var Custom = function Custom() {
return /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Test"));
};
var headers = [{
value: 'test'
}];
var rows = [{
test: 'test1',
other: 'other'
}];
var wrapper = mount( /*#__PURE__*/React.createElement(Table, {
customRow: Custom,
rows: rows,
headers: headers
}));
expect(wrapper.find(TableRow)).toHaveLength(0);
expect(wrapper.find(TableRowEmpty)).toHaveLength(0);
expect(wrapper.find(Custom)).toHaveLength(1);
});
it('Should display the ActionCollapse correctly without the rowLinks', function () {
var headers = [{
value: 'test'
}];
var rows = [{
test: 'test1',
other: 'other',
_isChecked: true
}];
var wrapper = mount( /*#__PURE__*/React.createElement(Table, {
rows: rows,
headers: headers,
withBulkAction: true
}));
var collapse = wrapper.find(ActionCollapse);
expect(collapse).toHaveLength(1);
expect(collapse.prop('colSpan')).toBe(2);
});
it('Should display the ActionCollapse correctly with the bulkAction', function () {
var headers = [{
value: 'test'
}];
var rows = [{
test: 'test1',
other: 'other',
_isChecked: true
}];
var rowLinks = [{
icon: 'trash',
onClick: jest.fn()
}];
var wrapper = mount( /*#__PURE__*/React.createElement(Table, {
rows: rows,
headers: headers,
rowLinks: rowLinks,
withBulkAction: true
}));
var collapse = wrapper.find(ActionCollapse);
expect(collapse).toHaveLength(1);
expect(collapse.prop('colSpan')).toBe(3);
});
it('Should display the ActionCollapse if one of the row is not checked', function () {
var headers = [{
value: 'test'
}];
var rows = [{
test: 'test1',
other: 'other',
_isChecked: true
}, {
test: 'test2',
other: 'other1',
_isChecked: false
}];
var rowLinks = [{
icon: 'trash',
onClick: jest.fn()
}];
var wrapper = mount( /*#__PURE__*/React.createElement(Table, {
rows: rows,
headers: headers,
rowLinks: rowLinks,
withBulkAction: true
}));
var collapse = wrapper.find(ActionCollapse);
expect(collapse).toHaveLength(1);
expect(collapse.prop('numberOfSelectedEntries')).toBe(1);
});
it('Should not display the ActionCollapse if the withBulkAction is false', function () {
var headers = [{
value: 'test'
}];
var rows = [{
test: 'test1',
other: 'other',
_isChecked: true
}, {
test: 'test2',
other: 'other1',
_isChecked: true
}];
var rowLinks = [{
icon: 'trash',
onClick: jest.fn()
}];
var wrapper = mount( /*#__PURE__*/React.createElement(Table, {
rows: rows,
headers: headers,
rowLinks: rowLinks
}));
var collapse = wrapper.find(ActionCollapse);
expect(collapse).toHaveLength(0);
});
}); |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0082 ]-- |