提交 2604623b 编写于 作者: A afc163

fix showInfo when precent is out of range

上级 0eb83577
......@@ -20,7 +20,7 @@ exports[`Progress render negetive progress 1`] = `
<span
class="ant-progress-text"
>
-20%
0%
</span>
</div>
</div>
......@@ -83,3 +83,31 @@ exports[`Progress render out-of-range progress 1`] = `
</div>
</div>
`;
exports[`Progress render out-of-range progress with info 1`] = `
<div
class="ant-progress ant-progress-line ant-progress-status-success ant-progress-show-info ant-progress-default"
>
<div>
<div
class="ant-progress-outer"
>
<div
class="ant-progress-inner"
>
<div
class="ant-progress-bg"
style="width: 100%; height: 8px;"
/>
</div>
</div>
<span
class="ant-progress-text"
>
<i
class="anticon anticon-check-circle"
/>
</span>
</div>
</div>
`;
......@@ -16,6 +16,11 @@ describe('Progress', () => {
expect(wrapper.render()).toMatchSnapshot();
});
it('render out-of-range progress with info', async () => {
const wrapper = mount(<Progress percent={120} showInfo />);
expect(wrapper.render()).toMatchSnapshot();
});
it('render negetive progress', async () => {
const wrapper = mount(<Progress percent={-20} />);
expect(wrapper.render()).toMatchSnapshot();
......
......@@ -82,11 +82,11 @@ export default class Progress extends React.Component<ProgressProps, {}> {
let text;
const iconType = (type === 'circle' || type === 'dashboard') ? '' : '-circle';
if (progressStatus === 'exception') {
text = format ? textFormatter(percent) : <Icon type={`cross${iconType}`} />;
text = format ? textFormatter(validProgress(percent)) : <Icon type={`cross${iconType}`} />;
} else if (progressStatus === 'success') {
text = format ? textFormatter(percent) : <Icon type={`check${iconType}`} />;
text = format ? textFormatter(validProgress(percent)) : <Icon type={`check${iconType}`} />;
} else {
text = textFormatter(percent);
text = textFormatter(validProgress(percent));
}
progressInfo = <span className={`${prefixCls}-text`}>{text}</span>;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册