2017-12-29 10:09:18 +08:00
|
|
|
import React from 'react';
|
2019-11-28 12:34:33 +08:00
|
|
|
import { LoadingOutlined } from '@ant-design/icons';
|
2022-06-01 13:45:51 +08:00
|
|
|
import { render } from '../../../tests/utils';
|
2019-08-13 14:07:17 +08:00
|
|
|
|
2017-12-29 10:09:18 +08:00
|
|
|
import List from '..';
|
|
|
|
|
|
|
|
describe('List', () => {
|
|
|
|
it('renders empty loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
};
|
2022-06-01 13:45:51 +08:00
|
|
|
const { container: wrapper } = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<List loading={loading} dataSource={[]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
2022-06-01 13:45:51 +08:00
|
|
|
expect(wrapper.querySelectorAll('.ant-list-empty-text')).toHaveLength(0);
|
2017-12-29 10:09:18 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders object loading', () => {
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
};
|
2022-06-01 13:45:51 +08:00
|
|
|
const { container: wrapper } = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<List loading={loading} dataSource={[1]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
2022-06-01 13:45:51 +08:00
|
|
|
expect(wrapper.querySelectorAll('.ant-spin-spinning')).toHaveLength(1);
|
2017-12-29 10:09:18 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders object loading with indicator', () => {
|
2019-11-28 12:34:33 +08:00
|
|
|
const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;
|
2017-12-29 10:09:18 +08:00
|
|
|
|
|
|
|
const loading = {
|
|
|
|
spinning: true,
|
|
|
|
indicator: antIcon,
|
|
|
|
};
|
2022-06-01 13:45:51 +08:00
|
|
|
const { container: wrapper } = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<List loading={loading} dataSource={[1]} renderItem={() => <List.Item />} />,
|
2017-12-29 10:09:18 +08:00
|
|
|
);
|
2022-06-01 13:45:51 +08:00
|
|
|
expect(wrapper.querySelectorAll('.anticon-loading')).toHaveLength(1);
|
2017-12-29 10:09:18 +08:00
|
|
|
});
|
|
|
|
});
|