From ff1ef9ebbe0b42c824ec00dd6a9b16ec32dc9998 Mon Sep 17 00:00:00 2001 From: Tony Hallett Date: Wed, 18 Mar 2020 17:09:45 +0000 Subject: [PATCH] correct test name --- .../src/TreeItem/TreeItem.test.js | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js index 6409de5ea6cca0..3d13c4c6d8e1dd 100644 --- a/packages/material-ui-lab/src/TreeItem/TreeItem.test.js +++ b/packages/material-ui-lab/src/TreeItem/TreeItem.test.js @@ -436,14 +436,33 @@ describe('', () => { expect(getByTestId('two')).to.have.focus; }); - it('moves focus to a sibling node after conditional rendering', () => { + it('moves focus to a child node', () => { + const { getByTestId } = render( + + + + + , + ); + + expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); + getByTestId('one').focus(); + fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); + expect(getByTestId('two')).to.have.focus; + }); + + it('moves focus to a child node works with a dynamic tree', () => { function TestComponent() { const [hide, setState] = React.useState(false); return ( - {!hide && ( @@ -457,31 +476,17 @@ describe('', () => { ); } - const { getByText, queryByText, getByTestId } = render(); + const { queryByTestId, getByTestId } = render(); - expect(getByText('one')).to.not.be.null; - fireEvent.click(getByText('Hide')); - expect(queryByText('one')).to.be.null; - fireEvent.click(getByText('Hide')); - expect(getByText('one')).to.not.be.null; - getByTestId('one').focus(); - fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); - - expect(getByTestId('two')).to.have.focus; - }); + expect(getByTestId('one')).to.not.be.null; + fireEvent.click(getByTestId('button')); + expect(queryByTestId('one')).to.be.null; + fireEvent.click(getByTestId('button')); + expect(getByTestId('one')).to.not.be.null; - it('moves focus to a child node', () => { - const { getByTestId } = render( - - - - - , - ); - - expect(getByTestId('one')).to.have.attribute('aria-expanded', 'true'); getByTestId('one').focus(); fireEvent.keyDown(document.activeElement, { key: 'ArrowDown' }); + expect(getByTestId('two')).to.have.focus; });