Skip to content

Commit

Permalink
feat: table filterSearch supports function (#34085)
Browse files Browse the repository at this point in the history
* feat: table filterSearch supports function

* feat: update for test

* feat: update document
  • Loading branch information
heiyu4585 committed Feb 25, 2022
1 parent 086e5d8 commit 2c56927
Show file tree
Hide file tree
Showing 10 changed files with 1,330 additions and 8 deletions.
42 changes: 42 additions & 0 deletions components/table/__tests__/Table.filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,48 @@ describe('Table.filter', () => {
expect(wrapper.find('li.ant-dropdown-menu-item').length).toBe(2);
});

it('should supports filterSearch has type of function', () => {
jest.useFakeTimers();
jest.spyOn(console, 'error').mockImplementation(() => undefined);
const wrapper = mount(
createTable({
columns: [
{
...column,
filters: [
{
text: '123',
value: '123',
},
{
text: 123456,
value: '456',
},
{
text: <span>123</span>,
value: '456',
},
],
filterSearch: (input, record) => record.value.indexOf(input) > -1,
},
],
}),
);
wrapper.find('span.ant-dropdown-trigger').simulate('click', nativeEvent);
act(() => {
jest.runAllTimers();
wrapper.update();
});
expect(wrapper.find(Menu).length).toBe(1);
expect(wrapper.find(Input).length).toBe(1);
expect(wrapper.find('li.ant-dropdown-menu-item').length).toBe(3);
wrapper
.find(Input)
.find('input')
.simulate('change', { target: { value: '456' } });
expect(wrapper.find('li.ant-dropdown-menu-item').length).toBe(2);
});

it('supports check all items', () => {
jest.useFakeTimers();
jest.spyOn(console, 'error').mockImplementation(() => undefined);
Expand Down
823 changes: 823 additions & 0 deletions components/table/__tests__/__snapshots__/demo-extend.test.ts.snap

Large diffs are not rendered by default.

0 comments on commit 2c56927

Please sign in to comment.