Skip to content

Commit dc67020

Browse files
committed
feat: test
1 parent fa25174 commit dc67020

File tree

1 file changed

+55
-19
lines changed

1 file changed

+55
-19
lines changed

tests/Expanded.spec.tsx

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,25 @@ describe('Table.Expanded', () => {
2525
domSpy.mockRestore();
2626
});
2727

28-
const columns: ColumnsType = [
29-
{
30-
title: 'key',
31-
dataIndex: 'key',
32-
width: 100,
33-
onCell: (_, index) => {
34-
const props: React.TdHTMLAttributes<HTMLTableCellElement> = {};
35-
if (index === 0) props.rowSpan = 1;
36-
if (index === 1) props.rowSpan = 2;
37-
if (index === 2) props.rowSpan = 0;
38-
if (index === 3) props.rowSpan = undefined;
39-
return props;
40-
},
41-
},
42-
Table.EXPAND_COLUMN,
43-
{ title: 'key2', dataIndex: 'key2', width: 100 },
44-
];
45-
const data = [{ key: 'a' }, { key: 'b' }, { key: 'c' }, { key: 'd' }];
46-
4728
it('expanded + rowSpan', async () => {
29+
const columns: ColumnsType = [
30+
{
31+
title: 'key',
32+
dataIndex: 'key',
33+
width: 100,
34+
onCell: (_, index) => {
35+
const props: React.TdHTMLAttributes<HTMLTableCellElement> = {};
36+
if (index === 0) props.rowSpan = 1;
37+
if (index === 1) props.rowSpan = 2;
38+
if (index === 2) props.rowSpan = 0;
39+
if (index === 3) props.rowSpan = undefined;
40+
return props;
41+
},
42+
},
43+
Table.EXPAND_COLUMN,
44+
{ title: 'key2', dataIndex: 'key2', width: 100 },
45+
];
46+
const data = [{ key: 'a' }, { key: 'b' }, { key: 'c' }, { key: 'd' }];
4847
const { container } = render(
4948
<Table<Record<string, any>>
5049
columns={columns}
@@ -84,4 +83,41 @@ describe('Table.Expanded', () => {
8483
expect(trList[7].querySelectorAll('td').length).toBe(1);
8584
expect(trList[7].querySelectorAll('td')[0].getAttribute('colspan')).toBe('3');
8685
});
86+
87+
it('expanded + sticky', async () => {
88+
const columns: ColumnsType = [
89+
{
90+
title: '手机号',
91+
dataIndex: 'a',
92+
width: 100,
93+
fixed: 'left',
94+
onCell: (_, index) => {
95+
const props: React.TdHTMLAttributes<HTMLTableCellElement> = {};
96+
if (index === 0) props.rowSpan = 1;
97+
if (index === 1) props.rowSpan = 2;
98+
if (index === 2) props.rowSpan = 0;
99+
return props;
100+
},
101+
},
102+
Table.EXPAND_COLUMN,
103+
{ title: 'Name', dataIndex: 'c' },
104+
];
105+
const data = [{ key: 'a' }, { key: 'b' }, { key: 'c' }, { key: 'd' }];
106+
const { container } = render(
107+
<Table<Record<string, any>>
108+
columns={columns}
109+
data={data}
110+
sticky
111+
expandable={{
112+
defaultExpandAllRows: true,
113+
expandedRowRender: record => <div>{record.key}</div>,
114+
}}
115+
/>,
116+
);
117+
console.log('container', container);
118+
await act(async () => {
119+
vi.runAllTimers();
120+
await Promise.resolve();
121+
});
122+
});
87123
});

0 commit comments

Comments
 (0)