Skip to content

Commit

Permalink
[Autocomplete] add test about IME behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
teramotodaiki committed Jan 31, 2020
1 parent d073071 commit bf38327
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,24 @@ describe('<Autocomplete />', () => {
fireEvent.keyDown(document.activeElement, { key: 'Enter' });
expect(container.querySelectorAll('[class*="MuiChip-root"]')).to.have.length(3);
});

it('should not fire change event until the IME is confirmed', () => {
const handleChange = spy();
render(
<Autocomplete
freeSolo
onChange={handleChange}
renderInput={params => <TextField {...params} autoFocus />}
/>,
);
// Actual behavior when "あ" (Japanese) is entered on macOS/Safari with IME
fireEvent.change(document.activeElement, { target: { value: 'あ' } });
fireEvent.keyDown(document.activeElement, { key: 'Enter', keyCode: 229 });
expect(handleChange.callCount).to.equal(0);
fireEvent.keyDown(document.activeElement, { key: 'Enter', keyCode: 13 });
expect(handleChange.callCount).to.equal(1);
expect(handleChange.args[0][1]).to.equal('あ');
});
});

describe('prop: onInputChange', () => {
Expand Down

0 comments on commit bf38327

Please sign in to comment.