mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
✅ increase Table code coverage
This commit is contained in:
parent
5e605043a1
commit
ed133cb859
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user