diff --git a/components/progress/Steps.tsx b/components/progress/Steps.tsx index 1849ecab3c..f02e66d19a 100644 --- a/components/progress/Steps.tsx +++ b/components/progress/Steps.tsx @@ -20,7 +20,7 @@ const Steps: React.FC = 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) { diff --git a/components/progress/__tests__/__snapshots__/demo.test.js.snap b/components/progress/__tests__/__snapshots__/demo.test.js.snap index f17754825c..5517731d0c 100644 --- a/components/progress/__tests__/__snapshots__/demo.test.js.snap +++ b/components/progress/__tests__/__snapshots__/demo.test.js.snap @@ -1415,7 +1415,7 @@ Array [ style="width:14px;height:8px" />
{ ); }); + it('should display correct step', () => { + const wrapper = mount(); + 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(); expect(wrapper.render()).toMatchSnapshot();