Skip to content

Commit 6161b26

Browse files
authored
Merge pull request #231 from react-component/expect-match
fix: onChange event target miss spread props
2 parents cfdcf03 + 8a16023 commit 6161b26

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
7171
onChange?.({
7272
target: {
7373
...props,
74+
type,
7475
checked: e.target.checked,
7576
},
7677
stopPropagation() {

tests/index.test.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ describe('rc-checkbox', () => {
168168
fireEvent.click(inputEl);
169169

170170
expect(onChange).toHaveBeenCalledTimes(1);
171+
expect(onChange).toHaveBeenCalledWith(
172+
expect.objectContaining({
173+
target: expect.objectContaining({ type: 'checkbox', checked: true }),
174+
}),
175+
);
171176
expect(inputEl.checked).toBe(true);
172177
});
173178

0 commit comments

Comments
 (0)