Skip to content

Commit

Permalink
test(useFusionTable): add onSort/onFilter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miracles1919 committed Jun 14, 2022
1 parent e25aab5 commit 50d4b6a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/hooks/src/useFusionTable/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,25 @@ describe('useFusionTable', () => {
expect(hook2.result.current.loading).toBeFalsy();
expect(hook2.result.current.tableProps.dataSource).toHaveLength(5);
});

it('onSort should be work', async () => {
const { result } = setup(getTableData);
act(() => {
result.current.tableProps.onSort('dataIndex', 'asc');
});
expect(result.current.loading).toBeTruthy();
expect(result.current.params[0]?.sorter).toMatchObject({ field: 'dataIndex', order: 'asc' });
});

it('onFilter should be work', async () => {
const { result } = setup(getTableData);
const filterParams = {
version: 3,
};
act(() => {
result.current.tableProps.onFilter(filterParams);
});
expect(result.current.loading).toBeTruthy();
expect(result.current.params[0]?.filters).toMatchObject(filterParams);
});
});

0 comments on commit 50d4b6a

Please sign in to comment.