-
-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathColgroup.spec.jsx
More file actions
96 lines (84 loc) 路 2.02 KB
/
Copy pathColgroup.spec.jsx
File metadata and controls
96 lines (84 loc) 路 2.02 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from 'react';
import { render } from '@testing-library/react';
import Table, { INTERNAL_COL_DEFINE } from '../src';
import Cell from '../src/Cell';
describe('Table.ColGroup', () => {
it('internal props should render', () => {
const columns = [
{
key: 'test',
[INTERNAL_COL_DEFINE]: { className: 'show-in-col' },
},
];
const { container } = render(<Table columns={columns} />);
const colEl = container.querySelector('colgroup col');
expect(colEl?.className).toEqual('show-in-col');
});
it('correct key', () => {
const column1 = {
key: 'bamboo',
width: 1,
};
const column2 = {
key: 'little',
width: 1,
};
const column3 = {
key: 'light',
width: 1,
};
let unmount = 0;
const ProxyCell = props => {
React.useEffect(() => {
return () => {
unmount += 1;
};
}, []);
return <th {...props} />;
};
const { rerender } = render(
<Table
columns={[column1, column2]}
components={{
header: {
cell: ProxyCell,
},
}}
/>,
);
rerender(
<Table
columns={[column2, column3]}
components={{
header: {
cell: ProxyCell,
},
}}
/>,
);
expect(unmount).toEqual(1);
});
it('minWidth should be worked', () => {
const columns = [
{
key: 0,
minWidth: 100,
},
];
const { container } = render(<Table columns={columns} />);
const colEl = container.querySelector('colgroup col');
expect(colEl?.style.minWidth).toEqual('100px');
});
it('should not have minWidth when tableLayout is fixed', () => {
const columns = [
{
key: 0,
width: 100,
minWidth: 100,
},
];
const { container } = render(<Table columns={columns} tableLayout="fixed" />);
const colEl = container.querySelector('colgroup col');
expect(colEl?.style.minWidth).toBeFalsy();
});
});