mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 12:38:58 +08:00
test: add test case for ref test (#19302)
* add test case for ref test * update test case
This commit is contained in:
parent
e7ebf857bd
commit
b9b239ec08
@ -43,7 +43,7 @@ describe('Table.filter', () => {
|
||||
];
|
||||
|
||||
const longData = [];
|
||||
for(let i = 0; i < 100; i += 1) {
|
||||
for (let i = 0; i < 100; i += 1) {
|
||||
longData.push({
|
||||
key: i.toString(),
|
||||
name: 'name',
|
||||
@ -854,11 +854,13 @@ describe('Table.filter', () => {
|
||||
|
||||
it('should reset pagination after filter', () => {
|
||||
const handleChange = jest.fn();
|
||||
const wrapper = mount(createTable({
|
||||
onChange: handleChange,
|
||||
dataSource: longData,
|
||||
pagination: true,
|
||||
}));
|
||||
const wrapper = mount(
|
||||
createTable({
|
||||
onChange: handleChange,
|
||||
dataSource: longData,
|
||||
pagination: true,
|
||||
}),
|
||||
);
|
||||
const dropdownWrapper = getDropdownWrapper(wrapper);
|
||||
|
||||
dropdownWrapper
|
||||
@ -883,13 +885,15 @@ describe('Table.filter', () => {
|
||||
|
||||
it('should keep pagination current after filter', () => {
|
||||
const handleChange = jest.fn();
|
||||
const wrapper = mount(createTable({
|
||||
onChange: handleChange,
|
||||
dataSource: longData,
|
||||
pagination: {
|
||||
current: 3,
|
||||
},
|
||||
}));
|
||||
const wrapper = mount(
|
||||
createTable({
|
||||
onChange: handleChange,
|
||||
dataSource: longData,
|
||||
pagination: {
|
||||
current: 3,
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(wrapper.find('.ant-pagination-item-active').text()).toBe('3');
|
||||
const dropdownWrapper = getDropdownWrapper(wrapper);
|
||||
|
||||
@ -912,4 +916,32 @@ describe('Table.filter', () => {
|
||||
);
|
||||
expect(wrapper.find('.ant-pagination-item-active').text()).toBe('3');
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/19274
|
||||
it('should not crash', () => {
|
||||
class TestTable extends React.Component {
|
||||
state = {
|
||||
cols: [],
|
||||
};
|
||||
|
||||
componentDidMount = () => {
|
||||
this.setState({
|
||||
cols: [
|
||||
{
|
||||
title: 'test',
|
||||
itemKey: 'test',
|
||||
filterDropdown: 123,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
render = () => {
|
||||
const { cols } = this.state;
|
||||
return <Table columns={cols} dataSource={[]} scroll={{ x: 1000 }} />;
|
||||
};
|
||||
}
|
||||
|
||||
mount(<TestTable />);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user