Skip to content

Commit

Permalink
test: fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Mar 10, 2020
1 parent 15ca801 commit 130e23d
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 51 deletions.
35 changes: 16 additions & 19 deletions components/table/__tests__/Table.filter.test.js
Expand Up @@ -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' }] });
Expand Down Expand Up @@ -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(
Expand All @@ -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();
});
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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']);
});
Expand Down Expand Up @@ -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();
Expand All @@ -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();
});

Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(),
{
Expand Down Expand Up @@ -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');
Expand Down
92 changes: 60 additions & 32 deletions components/table/__tests__/__snapshots__/Table.filter.test.js.snap
Expand Up @@ -508,16 +508,23 @@ exports[`Table.filter renders menu correctly 1`] = `
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
<button
class="ant-btn ant-btn-link ant-btn-sm"
disabled=""
type="button"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
<span>
Reset
</span>
</button>
<button
class="ant-btn ant-btn-primary ant-btn-sm"
type="button"
>
Reset
</a>
<span>
OK
</span>
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -605,16 +612,23 @@ exports[`Table.filter renders radio filter correctly 1`] = `
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
<button
class="ant-btn ant-btn-link ant-btn-sm"
disabled=""
type="button"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
<span>
Reset
</span>
</button>
<button
class="ant-btn ant-btn-primary ant-btn-sm"
type="button"
>
Reset
</a>
<span>
OK
</span>
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -769,16 +783,23 @@ exports[`Table.filter should support getPopupContainer 1`] = `
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
<button
class="ant-btn ant-btn-link ant-btn-sm"
disabled=""
type="button"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
<span>
Reset
</span>
</button>
<button
class="ant-btn ant-btn-primary ant-btn-sm"
type="button"
>
Reset
</a>
<span>
OK
</span>
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -995,16 +1016,23 @@ exports[`Table.filter should support getPopupContainer from ConfigProvider 1`] =
<div
class="ant-table-filter-dropdown-btns"
>
<a
class="ant-table-filter-dropdown-link confirm"
<button
class="ant-btn ant-btn-link ant-btn-sm"
disabled=""
type="button"
>
OK
</a>
<a
class="ant-table-filter-dropdown-link clear"
<span>
Reset
</span>
</button>
<button
class="ant-btn ant-btn-primary ant-btn-sm"
type="button"
>
Reset
</a>
<span>
OK
</span>
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 130e23d

Please sign in to comment.