Skip to content

Commit

Permalink
feat: 添加 defaultSelectedRowKeys 测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
keelii authored Mar 24, 2021
1 parent e0abe32 commit 38c9b8a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/table/__tests__/Table.rowSelection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ describe('Table.rowSelection', () => {
.filter(key => key !== null);
}

it('select default row', () => {
const wrapper = mount(createTable({ rowSelection: { defaultSelectedRowKeys: [0] } }));
const checkboxes = wrapper.find('input');

expect(getSelections(wrapper)).toEqual([0]);

checkboxes.at(1).simulate('change', { target: { checked: false } });
expect(getSelections(wrapper)).toEqual([]);

checkboxes.at(0).simulate('change', { target: { checked: true } });
expect(getSelections(wrapper)).toEqual([0, 1, 2, 3]);

checkboxes.at(0).simulate('change', { target: { checked: false } });
expect(getSelections(wrapper)).toEqual([]);
});

it('select by checkbox', () => {
const wrapper = mount(createTable());
const checkboxes = wrapper.find('input');
Expand Down

0 comments on commit 38c9b8a

Please sign in to comment.