Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('<Autocomplete />', () => {

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'),
Expand All @@ -266,7 +266,7 @@ describe('<Autocomplete />', () => {

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'));
});

Expand All @@ -284,7 +284,7 @@ describe('<Autocomplete />', () => {
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');
});

Expand All @@ -301,7 +301,7 @@ describe('<Autocomplete />', () => {
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');
});
});
Expand All @@ -320,7 +320,7 @@ describe('<Autocomplete />', () => {
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'),
Expand All @@ -340,7 +340,7 @@ describe('<Autocomplete />', () => {

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'),
Expand All @@ -362,7 +362,7 @@ describe('<Autocomplete />', () => {

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'),
Expand Down
76 changes: 38 additions & 38 deletions packages/material-ui-lab/src/TreeItem/TreeItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ describe('<TreeItem />', () => {
);

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', () => {
Expand All @@ -229,15 +229,15 @@ describe('<TreeItem />', () => {
);

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;
});
});

Expand All @@ -255,7 +255,7 @@ describe('<TreeItem />', () => {
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', () => {
Expand All @@ -270,7 +270,7 @@ describe('<TreeItem />', () => {
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', () => {
Expand All @@ -283,9 +283,9 @@ describe('<TreeItem />', () => {
);

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;
});
});

Expand All @@ -304,7 +304,7 @@ describe('<TreeItem />', () => {
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", () => {
Expand All @@ -319,7 +319,7 @@ describe('<TreeItem />', () => {
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');
});

Expand All @@ -341,7 +341,7 @@ describe('<TreeItem />', () => {
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');
});

Expand All @@ -357,7 +357,7 @@ describe('<TreeItem />', () => {
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', () => {
Expand All @@ -369,7 +369,7 @@ describe('<TreeItem />', () => {

getByTestId('one').focus();
fireEvent.keyDown(document.activeElement, { key: 'ArrowLeft' });
expect(getByTestId('one')).to.be.focused;
expect(getByTestId('one')).to.have.focus;
});
});

Expand All @@ -384,7 +384,7 @@ describe('<TreeItem />', () => {

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', () => {
Expand All @@ -399,7 +399,7 @@ describe('<TreeItem />', () => {
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", () => {
Expand All @@ -414,9 +414,9 @@ describe('<TreeItem />', () => {

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;
});
});

Expand All @@ -430,9 +430,9 @@ describe('<TreeItem />', () => {
);

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', () => {
Expand All @@ -446,9 +446,9 @@ describe('<TreeItem />', () => {

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", () => {
Expand All @@ -463,9 +463,9 @@ describe('<TreeItem />', () => {

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;
});
});

Expand All @@ -481,9 +481,9 @@ describe('<TreeItem />', () => {
);

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;
});
});

Expand All @@ -499,9 +499,9 @@ describe('<TreeItem />', () => {
);

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', () => {
Expand All @@ -519,9 +519,9 @@ describe('<TreeItem />', () => {
);

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;
});
});

Expand Down Expand Up @@ -569,15 +569,15 @@ describe('<TreeItem />', () => {
);

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', () => {
Expand All @@ -591,15 +591,15 @@ describe('<TreeItem />', () => {
);

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;
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui-lab/src/TreeView/TreeView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe('<TreeView />', () => {
const { getByText, getByTestId } = render(<MyComponent />);

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', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/ButtonBase/ButtonBase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ describe('<ButtonBase />', () => {
// so we need to check if we're resilient against it
const { getByText } = render(<ButtonBase autoFocus>Hello</ButtonBase>);

expect(getByText('Hello')).to.be.focused;
expect(getByText('Hello')).to.have.focus;
});
});

Expand Down Expand Up @@ -753,7 +753,7 @@ describe('<ButtonBase />', () => {
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');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('<ExpansionPanelSummary />', () => {
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);
});

Expand All @@ -90,7 +90,7 @@ describe('<ExpansionPanelSummary />', () => {

button.blur();

expect(button).not.to.be.focused;
expect(button).not.to.have.focus;
expect(button).not.to.have.class(classes.focused);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,15 @@ describe('<Modal />', () => {
const { getByRole, setProps } = render(<WithRemovableElement />);
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;
});
});
});
Expand Down
Loading