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/42326/head^2
不郑 2 years ago committed by GitHub
parent 8200e5ccb3
commit f3be5ddd0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -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', () => { it('should warnning if pass number[] into `size` in type dashboard', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<Progress size={[60, 20]} type="dashboard" />); render(<Progress size={[60, 20]} type="dashboard" />);

Loading…
Cancel
Save