Fix: successPercent should decide the progress status when it exists, close #9382 (#9614)

* fix: successPercent should decide the progress status when it exists, close #9382

* Add test for e361df0 that successPercent should decide the progress status when it exists
This commit is contained in:
诸岳 2018-03-11 00:11:52 +08:00 committed by GitHub
parent 398788b2c9
commit 40e7e0c193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,13 @@
import React from 'react';
import { mount } from 'enzyme';
import Progress from '..';
describe('Progress', () => {
it('successPercent should decide the progress status when it exists', async () => {
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);
});
});

View File

@ -60,8 +60,8 @@ export default class Progress extends React.Component<ProgressProps, {}> {
prefixCls, className, percent = 0, status, format, trailColor, size, successPercent,
type, strokeWidth, width, showInfo, gapDegree = 0, gapPosition, ...restProps,
} = props;
const progressStatus = parseInt(percent.toString(), 10) >= 100 && !('status' in props) ?
'success' : (status || 'normal');
const progressStatus = parseInt((successPercent ? successPercent.toString() : percent.toString()), 10) >= 100 &&
!('status' in props) ? 'success' : (status || 'normal');
let progressInfo;
let progress;
const textFormatter = format || (percentNumber => `${percentNumber}%`);