Browse Source

fix(Progress): prevent warning when size prop is not set for circle p… (#41875)

* fix(Progress): prevent warning when size prop is not set for circle progress

* fix(Progress): add test case for #41875

---------

Co-authored-by: lijianan <574980606@qq.com>
pull/41208/merge
不郑 2 years ago
committed by GitHub
parent
commit
f3be5ddd0e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/progress/Circle.tsx
  2. 7
      components/progress/__tests__/index.test.tsx

6
components/progress/Circle.tsx

@ -28,12 +28,10 @@ const Circle: React.FC<CircleProps> = (props) => {
type,
children,
success,
size,
size = originWidth,
} = props;
const mergedSize = size ?? [originWidth, originWidth];
const [width, height] = getSize(mergedSize, 'circle');
const [width, height] = getSize(size, 'circle');
let { strokeWidth } = props;
if (strokeWidth === undefined) {

7
components/progress/__tests__/index.test.tsx

@ -264,6 +264,13 @@ describe('Progress', () => {
);
});
it('should not warning if not pass the `size` prop in type Circle', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
errorSpy.mockClear();
render(<Progress type="circle" />);
expect(errorSpy).not.toHaveBeenCalled();
});
it('should warnning if pass number[] into `size` in type dashboard', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<Progress size={[60, 20]} type="dashboard" />);

Loading…
Cancel
Save