2018-08-22 23:34:36 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Skeleton from '..';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2018-08-22 23:34:36 +08:00
|
|
|
|
|
|
|
describe('Skeleton', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const genSkeleton = props =>
|
|
|
|
mount(
|
|
|
|
<Skeleton loading {...props}>
|
|
|
|
Bamboo
|
|
|
|
</Skeleton>,
|
|
|
|
);
|
2019-11-21 20:23:56 +08:00
|
|
|
const genSkeletonButton = props => mount(<Skeleton.Button {...props} />);
|
2019-12-03 13:33:04 +08:00
|
|
|
const genSkeletonAvatar = props => mount(<Skeleton.Avatar {...props} />);
|
2019-12-19 11:56:50 +08:00
|
|
|
const genSkeletonInput = props => mount(<Skeleton.Input {...props} />);
|
2020-06-12 22:44:32 +08:00
|
|
|
const genSkeletonImage = props => mount(<Skeleton.Image {...props} />);
|
2018-08-22 23:34:36 +08:00
|
|
|
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(Skeleton);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(Skeleton);
|
2019-08-26 22:53:20 +08:00
|
|
|
|
2019-11-21 20:23:56 +08:00
|
|
|
it('should without avatar and paragraph', () => {
|
|
|
|
const wrapperSmall = genSkeleton({ avatar: false, paragraph: false });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should square avatar', () => {
|
|
|
|
const wrapperSmall = genSkeleton({ avatar: true, paragraph: false });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2020-05-16 13:19:54 +08:00
|
|
|
it('should round title and paragraph', () => {
|
|
|
|
const wrapperSmall = genSkeleton({ round: true, title: true, paragraph: true });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
2020-06-12 22:44:32 +08:00
|
|
|
});
|
2020-05-16 13:19:54 +08:00
|
|
|
|
2018-08-22 23:34:36 +08:00
|
|
|
describe('avatar', () => {
|
|
|
|
it('size', () => {
|
|
|
|
const wrapperSmall = genSkeleton({ avatar: { size: 'small' } });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
const wrapperDefault = genSkeleton({ avatar: { size: 'default' } });
|
|
|
|
expect(wrapperDefault.render()).toMatchSnapshot();
|
|
|
|
const wrapperLarge = genSkeleton({ avatar: { size: 'large' } });
|
|
|
|
expect(wrapperLarge.render()).toMatchSnapshot();
|
2019-05-06 12:04:39 +08:00
|
|
|
const wrapperNumber = genSkeleton({ avatar: { size: 20 } });
|
|
|
|
expect(wrapperNumber.render()).toMatchSnapshot();
|
2018-08-22 23:34:36 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('shape', () => {
|
|
|
|
const wrapperCircle = genSkeleton({ avatar: { shape: 'circle' } });
|
|
|
|
expect(wrapperCircle.render()).toMatchSnapshot();
|
|
|
|
const wrapperSquare = genSkeleton({ avatar: { shape: 'square' } });
|
|
|
|
expect(wrapperSquare.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('title', () => {
|
|
|
|
it('width', () => {
|
|
|
|
const wrapper = genSkeleton({ title: { width: '93%' } });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('paragraph', () => {
|
|
|
|
it('rows', () => {
|
|
|
|
const wrapper = genSkeleton({ paragraph: { rows: 5 } });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('width', () => {
|
|
|
|
const wrapperPure = genSkeleton({ paragraph: { width: '93%' } });
|
|
|
|
expect(wrapperPure.render()).toMatchSnapshot();
|
|
|
|
const wrapperList = genSkeleton({ paragraph: { width: ['28%', '93%'] } });
|
|
|
|
expect(wrapperList.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2019-11-21 20:23:56 +08:00
|
|
|
|
2019-12-03 13:33:04 +08:00
|
|
|
describe('button element', () => {
|
2019-11-21 20:23:56 +08:00
|
|
|
it('active', () => {
|
|
|
|
const wrapper = genSkeletonButton({ active: true });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2021-06-10 00:38:55 +08:00
|
|
|
it('block', () => {
|
|
|
|
const wrapper = genSkeletonButton({ block: true });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2019-11-21 20:23:56 +08:00
|
|
|
it('size', () => {
|
|
|
|
const wrapperDefault = genSkeletonButton({ size: 'default' });
|
|
|
|
expect(wrapperDefault.render()).toMatchSnapshot();
|
|
|
|
const wrapperLarge = genSkeletonButton({ size: 'large' });
|
|
|
|
expect(wrapperLarge.render()).toMatchSnapshot();
|
|
|
|
const wrapperSmall = genSkeletonButton({ size: 'small' });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('shape', () => {
|
|
|
|
const wrapperDefault = genSkeletonButton({ shape: 'default' });
|
|
|
|
expect(wrapperDefault.render()).toMatchSnapshot();
|
|
|
|
const wrapperRound = genSkeletonButton({ shape: 'round' });
|
|
|
|
expect(wrapperRound.render()).toMatchSnapshot();
|
|
|
|
const wrapperCircle = genSkeletonButton({ shape: 'circle' });
|
|
|
|
expect(wrapperCircle.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2019-12-03 13:33:04 +08:00
|
|
|
|
|
|
|
describe('avatar element', () => {
|
|
|
|
it('active', () => {
|
|
|
|
const wrapper = genSkeletonAvatar({ active: true });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('size', () => {
|
|
|
|
const wrapperSmall = genSkeletonAvatar({ size: 'small' });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
const wrapperDefault = genSkeletonAvatar({ size: 'default' });
|
|
|
|
expect(wrapperDefault.render()).toMatchSnapshot();
|
|
|
|
const wrapperLarge = genSkeletonAvatar({ size: 'large' });
|
|
|
|
expect(wrapperLarge.render()).toMatchSnapshot();
|
|
|
|
const wrapperNumber = genSkeletonAvatar({ size: 20 });
|
|
|
|
expect(wrapperNumber.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shape', () => {
|
|
|
|
const wrapperCircle = genSkeletonAvatar({ shape: 'circle' });
|
|
|
|
expect(wrapperCircle.render()).toMatchSnapshot();
|
|
|
|
const wrapperSquare = genSkeletonAvatar({ shape: 'square' });
|
|
|
|
expect(wrapperSquare.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2019-12-19 11:56:50 +08:00
|
|
|
|
|
|
|
describe('input element', () => {
|
|
|
|
it('active', () => {
|
|
|
|
const wrapper = genSkeletonInput({ active: true });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('size', () => {
|
|
|
|
const wrapperSmall = genSkeletonInput({ size: 'small' });
|
|
|
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
|
|
|
const wrapperDefault = genSkeletonInput({ size: 'default' });
|
|
|
|
expect(wrapperDefault.render()).toMatchSnapshot();
|
|
|
|
const wrapperLarge = genSkeletonInput({ size: 'large' });
|
|
|
|
expect(wrapperLarge.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2020-06-12 22:44:32 +08:00
|
|
|
|
|
|
|
describe('image element', () => {
|
|
|
|
it('should render normal', () => {
|
|
|
|
const wrapper = genSkeletonImage();
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2021-12-24 14:23:32 +08:00
|
|
|
|
|
|
|
it('should support style', () => {
|
|
|
|
const wrapper = genSkeleton({ style: { background: 'blue' } });
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2018-08-22 23:34:36 +08:00
|
|
|
});
|