🐛 fix progress success UI when status is invalid

This commit is contained in:
afc163 2019-04-08 22:33:12 +08:00
parent 463ac0eccb
commit fbcc884b5b
No known key found for this signature in database
GPG Key ID: 5F00908D72002306
2 changed files with 11 additions and 3 deletions

View File

@ -94,7 +94,15 @@ describe('Progress', () => {
// https://github.com/ant-design/ant-design/issues/15950
it('should show success status when percent is 100 and status is undefined', () => {
const wrapper2 = mount(<Progress percent={100} status={undefined} />);
expect(wrapper2.find('.ant-progress-status-success')).toHaveLength(1);
const wrapper = mount(<Progress percent={100} status={undefined} />);
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(1);
});
// https://github.com/ant-design/ant-design/pull/15951#discussion_r273062969
it('should show success status when status is invalid', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const wrapper = mount(<Progress percent={100} status="invalid" />);
expect(wrapper.find('.ant-progress-status-success')).toHaveLength(1);
errorSpy.mockRestore();
});
});

View File

@ -67,7 +67,7 @@ export default class Progress extends React.Component<ProgressProps> {
successPercent !== undefined ? successPercent.toString() : percent.toString(),
10,
);
if (percentNumber >= 100 && status === undefined) {
if (percentNumber >= 100 && ProgressStatuses.indexOf(status!) < 0) {
return 'success';
}
return status || 'normal';