From 8a160239be6a23ff26b24d12768d405d4ccbaf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Wed, 10 May 2023 11:24:42 +0800 Subject: [PATCH] fix: event miss type --- src/index.tsx | 1 + tests/index.test.tsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index b047186..dec90d6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -71,6 +71,7 @@ export const Checkbox = forwardRef((props, ref) => { onChange?.({ target: { ...props, + type, checked: e.target.checked, }, stopPropagation() { diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 7f5fc19..0fd2a33 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -168,6 +168,11 @@ describe('rc-checkbox', () => { fireEvent.click(inputEl); expect(onChange).toHaveBeenCalledTimes(1); + expect(onChange).toHaveBeenCalledWith( + expect.objectContaining({ + target: expect.objectContaining({ type: 'checkbox', checked: true }), + }), + ); expect(inputEl.checked).toBe(true); });