Skip to content

Commit

Permalink
test(TagInput): add composing text with 'Enter'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvelSQ committed Jun 14, 2023
1 parent 95990d2 commit 2dd5f3e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/TagInput/test/TagInputSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,25 @@ describe('TagInput', () => {

expect(onChange).to.have.been.calledWith([]);
});

it('Should not create tag while text composing', () => {
const onCreateSpy = sinon.spy();
const inputRef = React.createRef<PickerHandle>();

render(<TagInput ref={inputRef} onCreate={onCreateSpy} creatable trigger="Enter" />);
const picker = (inputRef.current as PickerHandle).root as HTMLElement;
const input = screen.getByRole('textbox');

fireEvent.click(picker);

fireEvent.change(input, { target: { value: 'a' } });

fireEvent.keyDown(input, { key: 'Enter', isComposing: true });

expect(onCreateSpy).to.not.called;

fireEvent.keyDown(input, { key: 'Enter' });

expect(onCreateSpy).to.calledOnce;
});
});

0 comments on commit 2dd5f3e

Please sign in to comment.