-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathTable.order.test.js
More file actions
79 lines (68 loc) · 1.78 KB
/
Table.order.test.js
File metadata and controls
79 lines (68 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react';
import Enzyme, { mount } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import Table from '../index';
Enzyme.configure({ adapter: new Adapter() });
describe('Table.order', () => {
window.requestAnimationFrame = (callback) => window.setTimeout(callback, 16);
window.cancelAnimationFrame = window.clearTimeout;
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
afterEach(() => {
errorSpy.mockReset();
});
afterAll(() => {
errorSpy.mockRestore();
});
beforeAll(() => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
});
const columns = [
{
title: 'Name',
dataIndex: 'name',
},
];
const data = [
{ key: 0, name: 'Jack' },
{ key: 1, name: 'Lucy' },
{ key: 2, name: 'Tom' },
{ key: 3, name: 'Jerry' },
];
function createTable(props = {}) {
return <Table columns={columns} dataSource={data} {...props} />;
}
it('auto fixed', () => {
const wrapper = mount(
createTable({
columns: [
{
dataIndex: 'name',
fixed: true,
},
Table.SELECTION_COLUMN,
{
dataIndex: 'key',
},
],
rowSelection: {},
})
);
expect(
wrapper.find('tr').last().find('th').length +
wrapper.find('tr').last().find('td').length
).toBe(3);
wrapper.unmount();
});
});