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>
This commit is contained in:
不郑 2023-05-13 16:42:38 +08:00 committed by GitHub
parent 8200e5ccb3
commit f3be5ddd0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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) {

View File

@ -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" />);