From 7c92e978cab3004c9d50eb178367938a3677f3f0 Mon Sep 17 00:00:00 2001 From: joshwooding <12938082+joshwooding@users.noreply.github.com> Date: Wed, 29 Jul 2020 21:44:09 +0100 Subject: [PATCH] focusIn -> focus --- .../src/TreeItem/TreeItem.test.js | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js index 9e84c325a0a4d0..7e84cd011b80f7 100644 --- a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js +++ b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js @@ -355,7 +355,9 @@ describe('', () => { expect(getByTestId('one')).toHaveVirtualFocus(); - fireEvent.focusIn(getByTestId('two')); + act(() => { + getByTestId('two').focus(); + }); expect(getByTestId('two')).toHaveVirtualFocus(); }); @@ -1017,7 +1019,9 @@ describe('', () => { ); fireEvent.click(getByText('one')); - getByRole('tree').focus(); + act(() => { + getByRole('tree').focus(); + }); expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); @@ -1581,7 +1585,9 @@ describe('', () => { , ); - 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'); @@ -1597,7 +1603,9 @@ describe('', () => { , ); - 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'); @@ -1613,7 +1621,9 @@ describe('', () => { , ); - 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'); @@ -1632,7 +1642,9 @@ describe('', () => { , ); - 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'); @@ -1730,7 +1742,9 @@ describe('', () => { , ); - fireEvent.focusIn(getByTestId('five')); + act(() => { + getByTestId('five').focus(); + }); expect(getByTestId('five')).toHaveVirtualFocus(); fireEvent.keyDown(getByRole('tree'), { key: 'Home', @@ -1763,14 +1777,16 @@ describe('', () => { }); it('should not prevent programmatic focus', () => { - const { getByText, getByTestId } = render( + const { getByTestId } = render( , ); - fireEvent.focusIn(getByText('one')); + act(() => { + getByTestId('one').focus(); + }); expect(getByTestId('one')).toHaveVirtualFocus(); }); @@ -1839,14 +1855,16 @@ describe('', () => { }); it('should prevent programmatic focus', () => { - const { getByText, getByTestId } = render( + const { getByTestId } = render( , ); - fireEvent.focusIn(getByText('one')); + act(() => { + getByTestId('one').focus(); + }); expect(getByTestId('one')).not.toHaveVirtualFocus(); }); @@ -1914,7 +1932,9 @@ describe('', () => { , ); - 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' }); @@ -1931,7 +1951,9 @@ describe('', () => { , ); - 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' }); @@ -1948,7 +1970,9 @@ describe('', () => { , ); - 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' });