From 70f3a6af501005ca18b11bd7154d093e61335348 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Wed, 13 Nov 2019 21:41:01 +0100 Subject: [PATCH] [Autocomplete] Add tag keyboard navigation test --- .../src/Autocomplete/Autocomplete.test.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js index ab064355f91040..d64dc05227daff 100644 --- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js +++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js @@ -68,6 +68,29 @@ describe('', () => { 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( + } + 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', () => {