2017-12-29 10:09:18 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { render } from 'enzyme';
|
|
|
|
import List from '..';
|
|
|
|
import Icon from '../../icon';
|
|
|
|
|
|
|
|
describe('List', () => {
|
|
|
|
it('renders empty loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
};
|
|
|
|
const wrapper = render(
|
2018-12-07 20:02:01 +08:00
|
|
|
<List loading={loading} dataSource={[]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
|
|
|
expect(wrapper.find('.ant-list-empty-text')).toHaveLength(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders object loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
};
|
|
|
|
const wrapper = render(
|
2018-12-07 20:02:01 +08:00
|
|
|
<List loading={loading} dataSource={[1]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
|
|
|
expect(wrapper.find('.ant-spin-spinning')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders object loading with indicator', () => {
|
|
|
|
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
|
|
|
|
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
indicator: antIcon,
|
|
|
|
};
|
|
|
|
const wrapper = render(
|
2018-12-07 20:02:01 +08:00
|
|
|
<List loading={loading} dataSource={[1]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
|
|
|
expect(wrapper.find('.anticon-loading')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
});
|