From ebd31cdfc8220e846bdc794af83d511cdc9d9348 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 10 Mar 2020 18:38:02 +0800 Subject: [PATCH] test: fix test cases --- .../__snapshots__/components.test.js.snap | 69 +++++++++----- .../table/__tests__/Table.filter.test.js | 35 ++++--- .../__tests__/Table.rowSelection.test.js | 2 +- .../__snapshots__/Table.filter.test.js.snap | 92 ++++++++++++------- 4 files changed, 122 insertions(+), 76 deletions(-) diff --git a/components/config-provider/__tests__/__snapshots__/components.test.js.snap b/components/config-provider/__tests__/__snapshots__/components.test.js.snap index b3ad6ff279..a6f4d95707 100644 --- a/components/config-provider/__tests__/__snapshots__/components.test.js.snap +++ b/components/config-provider/__tests__/__snapshots__/components.test.js.snap @@ -11763,16 +11763,23 @@ exports[`ConfigProvider components Table configProvider 1`] = `
- - OK - - + Reset + + +
@@ -12102,16 +12109,23 @@ exports[`ConfigProvider components Table normal 1`] = `
- - OK - - + Reset + + +
@@ -12441,16 +12455,23 @@ exports[`ConfigProvider components Table prefixCls 1`] = `
- - OK - - + Reset + + +
diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js index 0f90ad8c63..c14d5eda27 100644 --- a/components/table/__tests__/Table.filter.test.js +++ b/components/table/__tests__/Table.filter.test.js @@ -235,7 +235,7 @@ describe('Table.filter', () => { .simulate('click'); wrapper .find('FilterDropdown') - .find('.confirm') + .find('.ant-table-filter-dropdown-btns .ant-btn-primary') .simulate('click'); expect(wrapper.find('FilterDropdown').props().filterState.filteredKeys).toEqual(['boy']); wrapper.setProps({ dataSource: [...data, { key: 999, name: 'Chris' }] }); @@ -379,7 +379,7 @@ describe('Table.filter', () => { .simulate('click'); wrapper .find('FilterDropdown') - .find('.confirm') + .find('.ant-table-filter-dropdown-btns .ant-btn-primary') .simulate('click'); expect(handleChange).toHaveBeenCalledWith( @@ -400,7 +400,7 @@ describe('Table.filter', () => { .find('.ant-dropdown-trigger') .first() .simulate('click'); - wrapper.find('.clear').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-link').simulate('click'); expect(handleChange).not.toHaveBeenCalled(); }); @@ -460,7 +460,7 @@ describe('Table.filter', () => { // .find('MenuItem') // .last() // .simulate('click'); - // dropdownWrapper.find('.confirm').simulate('click'); + // dropdownWrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); // wrapper.update(); // expect(renderedNames(wrapper)).toEqual(['Jack']); // dropdownWrapper @@ -501,7 +501,7 @@ describe('Table.filter', () => { .first() .simulate('click'); // This test can be remove if refactor - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); wrapper.update(); expect( @@ -581,11 +581,11 @@ describe('Table.filter', () => { .find('MenuItem') .first() .simulate('click'); - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); wrapper.update(); expect(renderedNames(wrapper)).toEqual(['Jack']); - wrapper.find('.clear').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-link').simulate('click'); wrapper.update(); expect(renderedNames(wrapper)).toEqual(['Jack', 'Lucy', 'Tom', 'Jerry']); }); @@ -872,7 +872,7 @@ describe('Table.filter', () => { .find('MenuItem') .first() .simulate('click'); - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); expect(onChange).toHaveBeenCalled(); onChange.mockReset(); expect(onChange).not.toHaveBeenCalled(); @@ -890,7 +890,7 @@ describe('Table.filter', () => { .find('MenuItem') .first() .simulate('click'); - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); expect(onChange).toHaveBeenCalled(); }); @@ -1025,7 +1025,7 @@ describe('Table.filter', () => { .find('MenuItem') .first() .simulate('click'); - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); expect(handleChange).toHaveBeenCalledWith( { @@ -1062,7 +1062,7 @@ describe('Table.filter', () => { .find('MenuItem') .first() .simulate('click'); - wrapper.find('.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); expect(handleChange).toHaveBeenCalledWith( { @@ -1155,7 +1155,7 @@ describe('Table.filter', () => { .find('.ant-dropdown-menu-item') .first() .simulate('click'); - wrapper.find('.ant-table-filter-dropdown-link.confirm').simulate('click'); + wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').simulate('click'); expect(onChange).toHaveBeenCalledWith( expect.anything(), { @@ -1185,15 +1185,12 @@ describe('Table.filter', () => { }), ); + expect(wrapper.find('.ant-table-filter-dropdown-btns .ant-btn-primary').text()).toEqual( + 'Bamboo', + ); expect( wrapper - .find('.ant-table-filter-dropdown-link') - .first() - .text(), - ).toEqual('Bamboo'); - expect( - wrapper - .find('.ant-table-filter-dropdown-link') + .find('.ant-table-filter-dropdown-btns .ant-btn-link') .last() .text(), ).toEqual('Reset'); diff --git a/components/table/__tests__/Table.rowSelection.test.js b/components/table/__tests__/Table.rowSelection.test.js index fbcc9ecc93..9a59df8c2f 100644 --- a/components/table/__tests__/Table.rowSelection.test.js +++ b/components/table/__tests__/Table.rowSelection.test.js @@ -623,7 +623,7 @@ describe('Table.rowSelection', () => { .simulate('click'); }); wrapper - .find('.ant-table-filter-dropdown-btns .ant-table-filter-dropdown-link.confirm') + .find('.ant-table-filter-dropdown-btns .ant-btn-primary') .simulate('click'); } diff --git a/components/table/__tests__/__snapshots__/Table.filter.test.js.snap b/components/table/__tests__/__snapshots__/Table.filter.test.js.snap index 2f90b5bddc..8e6c9ba231 100644 --- a/components/table/__tests__/__snapshots__/Table.filter.test.js.snap +++ b/components/table/__tests__/__snapshots__/Table.filter.test.js.snap @@ -508,16 +508,23 @@ exports[`Table.filter renders menu correctly 1`] = `
- - OK - - + Reset + + +
@@ -605,16 +612,23 @@ exports[`Table.filter renders radio filter correctly 1`] = `
- - OK - - + Reset + + +
@@ -769,16 +783,23 @@ exports[`Table.filter should support getPopupContainer 1`] = `
- - OK - - + Reset + + +
@@ -995,16 +1016,23 @@ exports[`Table.filter should support getPopupContainer from ConfigProvider 1`] =
- - OK - - + Reset + + +