From b9b239ec08565879c2a85140ea6caa409e4d86cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 19 Oct 2019 22:48:13 +0800 Subject: [PATCH] test: add test case for ref test (#19302) * add test case for ref test * update test case --- .../table/__tests__/Table.filter.test.js | 58 ++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js index c174a21f43..c0884c167a 100644 --- a/components/table/__tests__/Table.filter.test.js +++ b/components/table/__tests__/Table.filter.test.js @@ -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 ; + }; + } + + mount(); + }); });