2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
|
|
|
import Progress from '..';
|
2018-06-06 02:48:15 +00:00
|
|
|
|
|
|
|
describe('Progress', () => {
|
|
|
|
it('successPercent should decide the progress status when it exists', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-06-06 02:48:15 +00:00
|
|
|
percent: 100,
|
|
|
|
successPercent: 50,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-06-06 02:48:15 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(0);
|
|
|
|
});
|
2018-06-06 02:48:15 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
wrapper.setProps({ percent: 50, successPercent: 100 });
|
2018-06-06 02:48:15 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(1);
|
|
|
|
});
|
2019-04-30 05:31:21 +00:00
|
|
|
|
|
|
|
wrapper.setProps({ percent: 100, successPercent: 0 });
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(wrapper.findAll('.ant-progress-status-success')).toHaveLength(0);
|
|
|
|
});
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('render out-of-range progress', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
percent: 120,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('render out-of-range progress with info', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
percent: 120,
|
|
|
|
showInfo: true,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('render negetive progress', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
percent: -20,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('render negetive successPercent', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
percent: 50,
|
|
|
|
successPercent: -20,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('render negetive successPercent', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-09-05 13:28:54 +00:00
|
|
|
percent: 50,
|
|
|
|
successPercent: 10,
|
|
|
|
format: (percent, successPercent) => `${percent} ${successPercent}`,
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-10-30 07:10:16 +00:00
|
|
|
|
|
|
|
it('render format', async () => {
|
|
|
|
const wrapper = mount(Progress, {
|
2020-06-26 02:08:47 +00:00
|
|
|
props: {
|
2018-10-30 07:10:16 +00:00
|
|
|
percent: 50,
|
|
|
|
type: 'circle',
|
|
|
|
strokeColor: 'red',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-10-30 07:10:16 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2019-01-05 03:24:25 +00:00
|
|
|
|
|
|
|
it('render normal progress', () => {
|
2020-06-26 02:08:47 +00:00
|
|
|
const wrapper = mount(Progress, { props: { status: 'normal' } });
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|