Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Mar 11, 2024
1 parent 48cff5d commit a0ced8e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ describe('Input ref', () => {
inputSpy.mockRestore();
});

it('selectionXXX should pass', () => {
const onChange = jest.fn();
const { container } = render(<Input onChange={onChange} />);

const inputEl = container.querySelector('input')!;
fireEvent.change(inputEl, { target: { value: 'test' } });

expect(onChange).toHaveBeenCalled();
const event = onChange.mock.calls[0][0];
expect(event.target.selectionStart).toBe(4);
expect(event.target.selectionEnd).toBe(4);
});

it('input should work', () => {
const ref = React.createRef<InputRef>();
const { container } = render(<Input ref={ref} defaultValue="light" />);
Expand Down

0 comments on commit a0ced8e

Please sign in to comment.