2019-01-12 11:33:27 +08:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import List from '..';
|
2020-04-04 22:03:18 +08:00
|
|
|
import { LoadingOutlined } from '@ant-design/icons-vue';
|
2018-06-16 22:57:11 +08:00
|
|
|
|
|
|
|
describe('List', () => {
|
|
|
|
it('renders empty loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return <List loading={loading} dataSource={[]} renderItem={() => <List.Item />} />;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.findAll('.ant-list-empty-text')).toHaveLength(0);
|
|
|
|
});
|
2018-06-16 22:57:11 +08:00
|
|
|
|
|
|
|
it('renders object loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return <List loading={loading} dataSource={[1]} renderItem={() => <List.Item />} />;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.findAll('.ant-spin-spinning')).toHaveLength(1);
|
|
|
|
});
|
2018-06-16 22:57:11 +08:00
|
|
|
|
|
|
|
it('renders object loading with indicator', () => {
|
2019-01-12 11:33:27 +08:00
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<List
|
2018-06-16 22:57:11 +08:00
|
|
|
loading={{
|
|
|
|
spinning: true,
|
2020-04-04 22:03:18 +08:00
|
|
|
indicator: <LoadingOutlined style={{ fontSize: '24px' }} />,
|
2018-06-16 22:57:11 +08:00
|
|
|
}}
|
|
|
|
dataSource={[1]}
|
|
|
|
renderItem={() => <List.Item />}
|
|
|
|
/>
|
2019-01-12 11:33:27 +08:00
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.findAll('.anticon-loading')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
});
|