ant-design-vue/components/skeleton/__tests__/index.test.js

83 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import { asyncExpect } from '@/tests/utils';
import Skeleton from '..';
2018-12-10 03:34:51 +00:00
describe('Skeleton', () => {
const genSkeleton = props => {
const skeletonProps = {
propsData: {
loading: true,
...props,
},
slots: {
default: 'Bamboo',
},
sync: false,
2019-01-12 03:33:27 +00:00
};
return mount(Skeleton, skeletonProps);
};
2018-12-10 03:34:51 +00:00
describe('avatar', () => {
it('size', async () => {
2019-01-12 03:33:27 +00:00
const wrapperSmall = genSkeleton({ avatar: { size: 'small' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperSmall.html()).toMatchSnapshot();
});
2018-12-10 03:34:51 +00:00
2019-01-12 03:33:27 +00:00
const wrapperDefault = genSkeleton({ avatar: { size: 'default' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperDefault.html()).toMatchSnapshot();
});
2018-12-10 03:34:51 +00:00
2019-01-12 03:33:27 +00:00
const wrapperLarge = genSkeleton({ avatar: { size: 'large' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperLarge.html()).toMatchSnapshot();
});
});
2018-12-10 03:34:51 +00:00
it('shape', async () => {
2019-01-12 03:33:27 +00:00
const wrapperCircle = genSkeleton({ avatar: { shape: 'circle' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperCircle.html()).toMatchSnapshot();
});
2018-12-10 03:34:51 +00:00
2019-01-12 03:33:27 +00:00
const wrapperSquare = genSkeleton({ avatar: { shape: 'square' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperSquare.html()).toMatchSnapshot();
});
});
});
2018-12-10 03:34:51 +00:00
describe('title', () => {
it('width', async () => {
2019-01-12 03:33:27 +00:00
const wrapper = genSkeleton({ title: { width: '93%' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapper.html()).toMatchSnapshot();
});
});
});
2018-12-10 03:34:51 +00:00
describe('paragraph', () => {
it('rows', async () => {
2019-01-12 03:33:27 +00:00
const wrapper = genSkeleton({ paragraph: { rows: 5 } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapper.html()).toMatchSnapshot();
});
});
2018-12-10 03:34:51 +00:00
it('width', async () => {
2019-01-12 03:33:27 +00:00
const wrapperPure = genSkeleton({ paragraph: { width: '93%' } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperPure.html()).toMatchSnapshot();
});
2018-12-10 03:34:51 +00:00
2019-01-12 03:33:27 +00:00
const wrapperList = genSkeleton({ paragraph: { width: ['28%', '93%'] } });
2018-12-10 03:34:51 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(wrapperList.html()).toMatchSnapshot();
});
});
});
});