test: add test case for ref test (#19302)

* add test case for ref test

* update test case
This commit is contained in:
二货机器人 2019-10-19 22:48:13 +08:00 committed by 偏右
parent e7ebf857bd
commit b9b239ec08

View File

@ -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 />);
});
});