Skip to content

Commit

Permalink
focusIn -> focus
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Jul 29, 2020
1 parent 6b0394a commit 4749555
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions packages/material-ui-lab/src/TreeItem/TreeItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ describe('<TreeItem />', () => {

expect(getByTestId('one')).toHaveVirtualFocus();

fireEvent.focusIn(getByTestId('two'));
act(() => {
getByTestId('two').focus();
});
expect(getByTestId('two')).toHaveVirtualFocus();
});

Expand Down Expand Up @@ -1017,7 +1019,9 @@ describe('<TreeItem />', () => {
);

fireEvent.click(getByText('one'));
getByRole('tree').focus();
act(() => {
getByRole('tree').focus();
});

expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true');

Expand Down Expand Up @@ -1581,7 +1585,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).toHaveVirtualFocus();
fireEvent.keyDown(getByRole('tree'), { key: ' ' });
expect(getByTestId('one')).not.to.have.attribute('aria-selected');
Expand All @@ -1597,7 +1603,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).toHaveVirtualFocus();
fireEvent.keyDown(getByRole('tree'), { key: 'ArrowDown', shiftKey: true });
expect(getByTestId('one')).to.have.attribute('aria-selected', 'false');
Expand All @@ -1613,7 +1621,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).toHaveVirtualFocus();
fireEvent.keyDown(getByRole('tree'), { key: 'ArrowDown', shiftKey: true });
expect(getByTestId('one')).to.have.attribute('aria-selected', 'false');
Expand All @@ -1632,7 +1642,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).toHaveVirtualFocus();
fireEvent.keyDown(getByRole('tree'), { key: 'ArrowDown', shiftKey: true });
expect(getByTestId('one')).to.have.attribute('aria-selected', 'false');
Expand Down Expand Up @@ -1730,7 +1742,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('five'));
act(() => {
getByTestId('five').focus();
});
expect(getByTestId('five')).toHaveVirtualFocus();
fireEvent.keyDown(getByRole('tree'), {
key: 'Home',
Expand Down Expand Up @@ -1763,14 +1777,16 @@ describe('<TreeItem />', () => {
});

it('should not prevent programmatic focus', () => {
const { getByText, getByTestId } = render(
const { getByTestId } = render(
<TreeView disabledItemsFocusable>
<TreeItem nodeId="one" label="one" disabled data-testid="one" />
<TreeItem nodeId="two" label="two" data-testid="two" />
</TreeView>,
);

fireEvent.focusIn(getByText('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).toHaveVirtualFocus();
});

Expand Down Expand Up @@ -1839,14 +1855,16 @@ describe('<TreeItem />', () => {
});

it('should prevent programmatic focus', () => {
const { getByText, getByTestId } = render(
const { getByTestId } = render(
<TreeView>
<TreeItem nodeId="one" label="one" disabled data-testid="one" />
<TreeItem nodeId="two" label="two" data-testid="two" />
</TreeView>,
);

fireEvent.focusIn(getByText('one'));
act(() => {
getByTestId('one').focus();
});
expect(getByTestId('one')).not.toHaveVirtualFocus();
});

Expand Down Expand Up @@ -1914,7 +1932,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('two'));
act(() => {
getByTestId('two').focus();
});
expect(getByTestId('two')).toHaveVirtualFocus();
expect(getByTestId('two')).to.have.attribute('aria-expanded', 'false');
fireEvent.keyDown(getByRole('tree'), { key: 'Enter' });
Expand All @@ -1931,7 +1951,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('two'));
act(() => {
getByTestId('two').focus();
});
expect(getByTestId('two')).toHaveVirtualFocus();
expect(getByTestId('two')).to.have.attribute('aria-expanded', 'false');
fireEvent.keyDown(getByRole('tree'), { key: 'ArrowRight' });
Expand All @@ -1948,7 +1970,9 @@ describe('<TreeItem />', () => {
</TreeView>,
);

fireEvent.focusIn(getByTestId('two'));
act(() => {
getByTestId('two').focus();
});
expect(getByTestId('two')).toHaveVirtualFocus();
expect(getByTestId('two')).to.have.attribute('aria-expanded', 'true');
fireEvent.keyDown(getByRole('tree'), { key: 'ArrowLeft' });
Expand Down

0 comments on commit 4749555

Please sign in to comment.