diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js index aa9bc12b7e8fd1..d8039ce614a781 100644 --- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js +++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js @@ -246,7 +246,7 @@ describe('', () => { const textbox = getByRole('textbox'); const options = getAllByRole('option'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).to.have.attribute( 'aria-activedescendant', options[options.length - 1].getAttribute('id'), @@ -266,7 +266,7 @@ describe('', () => { const options = getAllByRole('option'); const textbox = getByRole('textbox'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).to.have.attribute('aria-activedescendant', options[0].getAttribute('id')); }); @@ -284,7 +284,7 @@ describe('', () => { fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); const textbox = getByRole('textbox'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).not.to.have.attribute('aria-activedescendant'); }); @@ -301,7 +301,7 @@ describe('', () => { fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); const textbox = getByRole('textbox'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).not.to.have.attribute('aria-activedescendant'); }); }); @@ -320,7 +320,7 @@ describe('', () => { fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); const textbox = getByRole('textbox'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).to.have.attribute( 'aria-activedescendant', getAllByRole('option')[0].getAttribute('id'), @@ -340,7 +340,7 @@ describe('', () => { const textbox = getByRole('textbox'); const options = getAllByRole('option'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).to.have.attribute( 'aria-activedescendant', options[options.length - 1].getAttribute('id'), @@ -362,7 +362,7 @@ describe('', () => { const textbox = getByRole('textbox'); const options = getAllByRole('option'); - expect(textbox).to.be.focused; + expect(textbox).to.have.focus; expect(textbox).to.have.attribute( 'aria-activedescendant', options[options.length - 1].getAttribute('id'), diff --git a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js index 7cd21eaa0e4fd7..3710ea837fd28d 100644 --- a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js +++ b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js @@ -207,12 +207,12 @@ describe('', () => { ); getByTestId('start').focus(); - expect(getByTestId('start')).to.be.focused; + expect(getByTestId('start')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'Tab' }); getByTestId('one').focus(); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it('should focus the selected node if a node is selected before the tree receives focus', () => { @@ -229,15 +229,15 @@ describe('', () => { ); fireEvent.click(getByText('two')); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; getByTestId('start').focus(); - expect(getByTestId('start')).to.be.focused; + expect(getByTestId('start')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'Tab' }); getByTestId('two').focus(); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); }); @@ -255,7 +255,7 @@ describe('', () => { getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' }); expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it('should move focus to the first child if focus is on an open node', () => { @@ -270,7 +270,7 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); it('should do nothing if focus is on an end node', () => { @@ -283,9 +283,9 @@ describe('', () => { ); fireEvent.click(getByText('two')); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowRight' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); }); @@ -304,7 +304,7 @@ describe('', () => { getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' }); expect(getByTestId('one')).to.have.attribute('aria-expanded', 'false'); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it("should move focus to the node's parent node if focus is on a child node that is an end node", () => { @@ -319,7 +319,7 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); fireEvent.click(getByText('two')); fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); }); @@ -341,7 +341,7 @@ describe('', () => { fireEvent.click(getByText('two')); expect(getByTestId('two')).to.have.attribute('aria-expanded', 'false'); fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); }); @@ -357,7 +357,7 @@ describe('', () => { getByTestId('one').focus(); expect(getByTestId('one')).to.have.attribute('aria-expanded', 'false'); fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it('should do nothing if focus is on a root node that is an end node', () => { @@ -369,7 +369,7 @@ describe('', () => { getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); }); @@ -384,7 +384,7 @@ describe('', () => { getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); it('moves focus to a nested node', () => { @@ -399,7 +399,7 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); it("moves focus to a parent's sibling", () => { @@ -414,9 +414,9 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); fireEvent.click(getByText('two')); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - expect(getByTestId('three')).to.be.focused; + expect(getByTestId('three')).to.have.focus; }); }); @@ -430,9 +430,9 @@ describe('', () => { ); fireEvent.click(getByText('two')); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it('moves focus to a parent', () => { @@ -446,9 +446,9 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); fireEvent.click(getByText('two')); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it("moves focus to a sibling's child", () => { @@ -463,9 +463,9 @@ describe('', () => { expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); fireEvent.click(getByText('three')); - expect(getByTestId('three')).to.be.focused; + expect(getByTestId('three')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); }); @@ -481,9 +481,9 @@ describe('', () => { ); fireEvent.click(getByText('four')); - expect(getByTestId('four')).to.be.focused; + expect(getByTestId('four')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'Home' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); }); @@ -499,9 +499,9 @@ describe('', () => { ); getByTestId('one').focus(); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'End' }); - expect(getByTestId('four')).to.be.focused; + expect(getByTestId('four')).to.have.focus; }); it('moves focus to the last node in the tree with expanded items', () => { @@ -519,9 +519,9 @@ describe('', () => { ); getByTestId('one').focus(); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'End' }); - expect(getByTestId('six')).to.be.focused; + expect(getByTestId('six')).to.have.focus; }); }); @@ -569,15 +569,15 @@ describe('', () => { ); getByTestId('one').focus(); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 't' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'f' }); - expect(getByTestId('four')).to.be.focused; + expect(getByTestId('four')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'o' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; }); it('moves focus to the next node with the same starting character', () => { @@ -591,15 +591,15 @@ describe('', () => { ); getByTestId('one').focus(); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 't' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 't' }); - expect(getByTestId('three')).to.be.focused; + expect(getByTestId('three')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 't' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); }); diff --git a/packages/material-ui-lab/src/TreeView/TreeView.test.js b/packages/material-ui-lab/src/TreeView/TreeView.test.js index 8da004813da548..e788328ad98b32 100644 --- a/packages/material-ui-lab/src/TreeView/TreeView.test.js +++ b/packages/material-ui-lab/src/TreeView/TreeView.test.js @@ -50,13 +50,13 @@ describe('', () => { const { getByText, getByTestId } = render(); fireEvent.click(getByText('one')); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowUp' }); - expect(getByTestId('one')).to.be.focused; + expect(getByTestId('one')).to.have.focus; fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - expect(getByTestId('two')).to.be.focused; + expect(getByTestId('two')).to.have.focus; }); describe('onNodeToggle', () => { diff --git a/packages/material-ui/src/ButtonBase/ButtonBase.test.js b/packages/material-ui/src/ButtonBase/ButtonBase.test.js index ec804840a8abeb..8bd4f0bd939692 100644 --- a/packages/material-ui/src/ButtonBase/ButtonBase.test.js +++ b/packages/material-ui/src/ButtonBase/ButtonBase.test.js @@ -608,7 +608,7 @@ describe('', () => { // so we need to check if we're resilient against it const { getByText } = render(Hello); - expect(getByText('Hello')).to.be.focused; + expect(getByText('Hello')).to.have.focus; }); }); @@ -753,7 +753,7 @@ describe('', () => { expect(typeof buttonActionsRef.current.focusVisible).to.equal('function'); // @ts-ignore buttonActionsRef.current.focusVisible(); - expect(getByText('Hello')).to.be.focused; + expect(getByText('Hello')).to.have.focus; expect(getByText('Hello')).to.match('.focusVisible'); }); }); diff --git a/packages/material-ui/src/ExpansionPanelSummary/ExpansionPanelSummary.test.js b/packages/material-ui/src/ExpansionPanelSummary/ExpansionPanelSummary.test.js index 662a33c0fea77d..313c0744510607 100644 --- a/packages/material-ui/src/ExpansionPanelSummary/ExpansionPanelSummary.test.js +++ b/packages/material-ui/src/ExpansionPanelSummary/ExpansionPanelSummary.test.js @@ -77,7 +77,7 @@ describe('', () => { fireEvent.keyDown(document.activeElement, { key: 'Tab' }); // not actually focusing (yet) button.focus(); - expect(button).to.be.focused; + expect(button).to.have.focus; expect(button).to.have.class(classes.focused); }); @@ -90,7 +90,7 @@ describe('', () => { button.blur(); - expect(button).not.to.be.focused; + expect(button).not.to.have.focus; expect(button).not.to.have.class(classes.focused); }); diff --git a/packages/material-ui/src/Modal/Modal.test.js b/packages/material-ui/src/Modal/Modal.test.js index 038fc6195d3ca3..71e8051dda4799 100644 --- a/packages/material-ui/src/Modal/Modal.test.js +++ b/packages/material-ui/src/Modal/Modal.test.js @@ -589,15 +589,15 @@ describe('', () => { const { getByRole, setProps } = render(); const dialog = getByRole('dialog'); const toggleButton = getByRole('button'); - expect(dialog).to.be.focused; + expect(dialog).to.have.focus; toggleButton.focus(); - expect(toggleButton).to.be.focused; + expect(toggleButton).to.have.focus; setProps({ hideButton: true }); - expect(dialog).to.not.be.focused; + expect(dialog).not.to.have.focus; clock.tick(500); // wait for the interval check to kick in. - expect(dialog).to.be.focused; + expect(dialog).to.have.focus; }); }); }); diff --git a/packages/material-ui/src/Select/Select.test.js b/packages/material-ui/src/Select/Select.test.js index 2e782e3625f45f..d334fd739116f9 100644 --- a/packages/material-ui/src/Select/Select.test.js +++ b/packages/material-ui/src/Select/Select.test.js @@ -201,7 +201,7 @@ describe('', () => { getByRole('listbox').focus(); - expect(getByRole('listbox')).to.be.focused; + expect(getByRole('listbox')).to.have.focus; }); it('identifies each selectable element containing an option', () => { @@ -815,7 +815,7 @@ describe('); - expect(getByRole('button')).to.be.focused; + expect(getByRole('button')).to.have.focus; }); }); @@ -849,7 +849,7 @@ describe(' integration', () => { trigger.click(); const options = getAllByRole('option'); - expect(options[1]).to.be.focused; + expect(options[1]).to.have.focus; // Now, let's close the select component getByTestId('select-backdrop').click(); clock.tick(0); expect(queryByRole('listbox')).to.be.null; - expect(trigger).to.focused; + expect(trigger).to.have.focus; }); it('should be able to change the selected item', () => { @@ -85,14 +85,14 @@ describe('