mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
fix: percent={(3 / 9) * 100} steps={9} shows 2 (#28530)
* 🐛 fix bug: percent={(3 / 9) * 100} steps={9} shows 2 * ✅ add test for last commit * ✨ update jest snapshot * ✅ add test
This commit is contained in:
parent
5098ca8b60
commit
d769795aa0
@ -20,7 +20,7 @@ const Steps: React.FC<StepsProps> = props => {
|
||||
prefixCls,
|
||||
children,
|
||||
} = props;
|
||||
const current = Math.floor(steps * (percent / 100));
|
||||
const current = Math.round(steps * (percent / 100));
|
||||
const stepWidth = size === 'small' ? 2 : 14;
|
||||
const styledSteps = [];
|
||||
for (let i = 0; i < steps; i += 1) {
|
||||
|
@ -1415,7 +1415,7 @@ Array [
|
||||
style="width:14px;height:8px"
|
||||
/>
|
||||
<div
|
||||
class="ant-progress-steps-item"
|
||||
class="ant-progress-steps-item ant-progress-steps-item-active"
|
||||
style="width:14px;height:8px"
|
||||
/>
|
||||
<div
|
||||
@ -1442,7 +1442,7 @@ Array [
|
||||
style="width:14px;height:8px"
|
||||
/>
|
||||
<div
|
||||
class="ant-progress-steps-item"
|
||||
class="ant-progress-steps-item ant-progress-steps-item-active"
|
||||
style="width:14px;height:8px"
|
||||
/>
|
||||
<div
|
||||
|
@ -175,6 +175,15 @@ describe('Progress', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should display correct step', () => {
|
||||
const wrapper = mount(<Progress steps={9} percent={22.22} />);
|
||||
expect(wrapper.find('.ant-progress-steps-item-active').length).toBe(2);
|
||||
wrapper.setProps({ percent: 33.33 });
|
||||
expect(wrapper.find('.ant-progress-steps-item-active').length).toBe(3);
|
||||
wrapper.setProps({ percent: 44.44 });
|
||||
expect(wrapper.find('.ant-progress-steps-item-active').length).toBe(4);
|
||||
});
|
||||
|
||||
it('steps should have default percent 0', () => {
|
||||
const wrapper = mount(<ProgressSteps />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
|
Loading…
Reference in New Issue
Block a user