Skip to content

Commit

Permalink
[Autocomplete] Add tag keyboard navigation test
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 13, 2019
1 parent 45779b9 commit 4ea1355
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
Expand Up @@ -68,6 +68,29 @@ describe('<Autocomplete />', () => {
expect(handleChange.callCount).to.equal(1);
expect(handleChange.args[0][1]).to.deep.equal([options[0]]);
});

it('navigates between different tags', () => {
const handleChange = spy();
const options = ['one', 'two'];
const { getByRole } = render(
<Autocomplete
defaultValue={options}
options={options}
onChange={handleChange}
renderInput={params => <TextField autoFocus {...params} />}
multiple
/>,
);
const textbox = getByRole('textbox');
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
expect(document.activeElement).to.have.text('two')
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
expect(document.activeElement).to.have.text('one')
fireEvent.keyDown(document.activeElement, { key: 'Backspace' });
expect(handleChange.callCount).to.equal(1);
expect(handleChange.args[0][1]).to.deep.equal([options[1]]);
expect(document.activeElement).to.equal(textbox);
});
});

describe('WAI-ARIA conforming markup', () => {
Expand Down

0 comments on commit 4ea1355

Please sign in to comment.