From 60dad5dd660c6c8ab720173ccbe1f6a025c0d1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Wed, 7 Aug 2024 19:27:14 +0800 Subject: [PATCH 1/2] fix: fix error when pass onClear --- src/Input.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Input.tsx b/src/Input.tsx index c2a7e23..c152f0d 100644 --- a/src/Input.tsx +++ b/src/Input.tsx @@ -214,6 +214,7 @@ const Input = forwardRef((props, ref) => { 'htmlSize', 'styles', 'classNames', + 'onClear', ], ); return ( From 5a2537ca02e2b324501d89ad5e60f89edbbaa092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Wed, 7 Aug 2024 20:03:21 +0800 Subject: [PATCH 2/2] test: add test case --- tests/index.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 59a5a26..ea76fbe 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -415,6 +415,7 @@ describe('Input ref', () => { it('support onClear', () => { const onClear = jest.fn(); + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const { container } = render( , ); @@ -422,6 +423,8 @@ describe('Input ref', () => { container.querySelector('.rc-input-clear-icon')!, ); expect(onClear).toHaveBeenCalled(); + expect(errorSpy).not.toHaveBeenCalled(); + errorSpy.mockRestore(); }); });