increase Table code coverage

This commit is contained in:
afc163 2019-08-27 17:11:00 +08:00
parent 5e605043a1
commit ed133cb859
3 changed files with 32 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import { render, mount } from 'enzyme';
import Table from '..';
import Select from '../../select';
describe('Table.pagination', () => {
const columns = [
@ -211,4 +212,21 @@ describe('Table.pagination', () => {
expect(wrapper.find('.ant-table-tbody tr.ant-table-row')).toHaveLength(data.length);
});
it('select by checkbox to trigger stopPropagation', () => {
const onShowSizeChange = jest.fn();
const wrapper = mount(
createTable({
pagination: {
total: 200,
showSizeChanger: true,
onShowSizeChange,
},
}),
);
wrapper.find(Select).simulate('click');
expect(wrapper.find('MenuItem').length).toBe(4);
wrapper.find('MenuItem').at(3).simulate('click');
expect(onShowSizeChange).toHaveBeenCalled();
});
});

View File

@ -714,4 +714,11 @@ describe('Table.rowSelection', () => {
wrapper.setProps({ rowSelection: null });
expect(wrapper.find('.ant-table-row-selected').length).toBe(0);
});
it('select by checkbox to trigger stopPropagation', () => {
const wrapper = mount(createTable());
expect(() => {
wrapper.find('span').at(10).simulate('click');
}).not.toThrow();
});
});

View File

@ -96,4 +96,11 @@ describe('Table', () => {
'Warning: [antd: Table] `expandedRowRender` and `Column.fixed` are not compatible. Please use one of them at one time.',
);
});
it('support onHeaderCell', () => {
const onClick = jest.fn();
const wrapper = mount(<Table columns={[{ title: 'title', onHeaderCell: () => ({ onClick }) }]} />);
wrapper.find('th').simulate('click');
expect(onClick).toHaveBeenCalled();
});
});