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 = []; const longData = [];
for(let i = 0; i < 100; i += 1) { for (let i = 0; i < 100; i += 1) {
longData.push({ longData.push({
key: i.toString(), key: i.toString(),
name: 'name', name: 'name',
@ -854,11 +854,13 @@ describe('Table.filter', () => {
it('should reset pagination after filter', () => { it('should reset pagination after filter', () => {
const handleChange = jest.fn(); const handleChange = jest.fn();
const wrapper = mount(createTable({ const wrapper = mount(
onChange: handleChange, createTable({
dataSource: longData, onChange: handleChange,
pagination: true, dataSource: longData,
})); pagination: true,
}),
);
const dropdownWrapper = getDropdownWrapper(wrapper); const dropdownWrapper = getDropdownWrapper(wrapper);
dropdownWrapper dropdownWrapper
@ -883,13 +885,15 @@ describe('Table.filter', () => {
it('should keep pagination current after filter', () => { it('should keep pagination current after filter', () => {
const handleChange = jest.fn(); const handleChange = jest.fn();
const wrapper = mount(createTable({ const wrapper = mount(
onChange: handleChange, createTable({
dataSource: longData, onChange: handleChange,
pagination: { dataSource: longData,
current: 3, pagination: {
}, current: 3,
})); },
}),
);
expect(wrapper.find('.ant-pagination-item-active').text()).toBe('3'); expect(wrapper.find('.ant-pagination-item-active').text()).toBe('3');
const dropdownWrapper = getDropdownWrapper(wrapper); const dropdownWrapper = getDropdownWrapper(wrapper);
@ -912,4 +916,32 @@ describe('Table.filter', () => {
); );
expect(wrapper.find('.ant-pagination-item-active').text()).toBe('3'); 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 />);
});
}); });