2019-07-22 19:28:23 +08:00
|
|
|
/* eslint-disable react/no-multi-comp */
|
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Table from '..';
|
|
|
|
|
2019-09-28 15:22:27 +08:00
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
key: 'name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
},
|
|
|
|
];
|
2019-07-22 19:28:23 +08:00
|
|
|
|
2019-09-28 15:22:27 +08:00
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
firstName: 'John',
|
|
|
|
lastName: 'Brown',
|
|
|
|
age: 32,
|
2019-07-22 19:28:23 +08:00
|
|
|
|
2019-09-28 15:22:27 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
firstName: 'Jim',
|
|
|
|
lastName: 'Green',
|
|
|
|
age: 42,
|
2019-07-22 19:28:23 +08:00
|
|
|
},
|
2019-09-28 15:22:27 +08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2019-07-22 19:28:23 +08:00
|
|
|
|
2019-09-28 15:22:27 +08:00
|
|
|
describe('Table.expand', () => {
|
|
|
|
it('click to expand', () => {
|
2019-07-22 19:28:23 +08:00
|
|
|
const wrapper = mount(<Table columns={columns} dataSource={data} />);
|
|
|
|
wrapper
|
|
|
|
.find('.ant-table-row-expand-icon')
|
|
|
|
.last()
|
|
|
|
.simulate('click');
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2019-09-28 15:22:27 +08:00
|
|
|
|
|
|
|
it('should support expandIconColumnIndex', () => {
|
|
|
|
const wrapper = mount(<Table columns={[]} dataSource={data} expandIconColumnIndex={1} />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2019-07-22 19:28:23 +08:00
|
|
|
});
|