Skip to content

Commit

Permalink
fix: fix error when pass onClear (#75)
Browse files Browse the repository at this point in the history
* fix: fix error when pass onClear

* test: add test case
  • Loading branch information
li-jia-nan committed Aug 7, 2024
1 parent a7392a9 commit 26d367d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
'htmlSize',
'styles',
'classNames',
'onClear',
],
);
return (
Expand Down
3 changes: 3 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,16 @@ describe('Input ref', () => {

it('support onClear', () => {
const onClear = jest.fn();
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(
<Input onClear={onClear} defaultValue="test" allowClear />,
);
fireEvent.click(
container.querySelector<HTMLSpanElement>('.rc-input-clear-icon')!,
);
expect(onClear).toHaveBeenCalled();
expect(errorSpy).not.toHaveBeenCalled();
errorSpy.mockRestore();
});
});

Expand Down

0 comments on commit 26d367d

Please sign in to comment.