2018-03-11 00:11:52 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Progress from '..';
|
|
|
|
|
|
|
|
describe('Progress', () => {
|
2018-04-29 23:01:58 +08:00
|
|
|
it('successPercent should decide the progress status when it exists', () => {
|
2018-03-11 00:11:52 +08:00
|
|
|
const wrapper = mount(<Progress percent={100} successPercent={50} />);
|
|
|
|
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(0);
|
|
|
|
|
|
|
|
wrapper.setProps({ percent: 50, successPercent: 100 });
|
|
|
|
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(1);
|
|
|
|
});
|
2018-04-18 10:45:07 +08:00
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render out-of-range progress', () => {
|
2018-04-18 10:45:07 +08:00
|
|
|
const wrapper = mount(<Progress percent={120} />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render out-of-range progress with info', () => {
|
2018-04-18 11:10:32 +08:00
|
|
|
const wrapper = mount(<Progress percent={120} showInfo />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render negetive progress', () => {
|
2018-04-18 10:45:07 +08:00
|
|
|
const wrapper = mount(<Progress percent={-20} />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render negetive successPercent', () => {
|
2018-04-18 10:45:07 +08:00
|
|
|
const wrapper = mount(<Progress percent={50} successPercent={-20} />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2018-04-29 23:01:58 +08:00
|
|
|
|
|
|
|
it('render format', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Progress
|
|
|
|
percent={50}
|
|
|
|
successPercent={10}
|
|
|
|
format={(percent, successPercent) => `${percent} ${successPercent}`}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2018-10-13 01:19:41 +08:00
|
|
|
|
|
|
|
it('render strokeColor', () => {
|
|
|
|
const wrapper = mount(<Progress type="circle" percent={50} strokeColor="red" />);
|
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
2018-03-11 00:11:52 +08:00
|
|
|
});
|