From f3be5ddd0eae511a410fb81bffb4c742fa1c46fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E9=83=91?= <13414731+notzheng@users.noreply.github.com> Date: Sat, 13 May 2023 16:42:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(Progress):=20prevent=20warning=20when=20siz?= =?UTF-8?q?e=20prop=20is=20not=20set=20for=20circle=20p=E2=80=A6=20(#41875?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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> --- components/progress/Circle.tsx | 6 ++---- components/progress/__tests__/index.test.tsx | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/progress/Circle.tsx b/components/progress/Circle.tsx index 06cb3acb16..67cf06731f 100644 --- a/components/progress/Circle.tsx +++ b/components/progress/Circle.tsx @@ -28,12 +28,10 @@ const Circle: React.FC = (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) { diff --git a/components/progress/__tests__/index.test.tsx b/components/progress/__tests__/index.test.tsx index ab2f75a30a..01449854f7 100644 --- a/components/progress/__tests__/index.test.tsx +++ b/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(); + expect(errorSpy).not.toHaveBeenCalled(); + }); + it('should warnning if pass number[] into `size` in type dashboard', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); render();