increase Table test coverage

This commit is contained in:
afc163 2019-09-28 18:14:28 +08:00 committed by 偏右
parent fb913f4f47
commit 916c0659bd
2 changed files with 53 additions and 0 deletions

View File

@ -70,6 +70,15 @@ describe('Table.pagination', () => {
expect(renderedNames(wrapper)).toEqual(['Jack']);
});
it('should accept pagination size', () => {
const wrapper = mount(
createTable({
pagination: { size: 'small' },
}),
);
expect(wrapper.find('.ant-pagination.mini')).toHaveLength(1);
});
// TODO
it('should scroll to first row when page change', () => {
const wrapper = mount(createTable({ scroll: { y: 20 } }));

View File

@ -630,4 +630,48 @@ describe('Table.sorter', () => {
wrapper.find('th').simulate('click');
expect(onClick).toHaveBeenCalled();
});
it('could sort data with children', () => {
const wrapper = mount(
createTable(
{
dataSource: [
{
key: '1',
name: 'Brown',
children: [
{
key: '2',
name: 'Zoe',
},
{
key: '3',
name: 'Mike',
children: [
{
key: '3-1',
name: 'Petter',
},
{
key: '3-2',
name: 'Alex',
},
],
},
{
key: '4',
name: 'Green',
},
],
},
],
},
{
defaultSortOrder: 'ascend',
},
),
);
expect(renderedNames(wrapper)).toEqual(['Brown', 'Green', 'Mike', 'Alex', 'Petter', 'Zoe']);
});
});