Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Feb 26, 2020
1 parent e392b78 commit f430c97
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/material-ui-lab/src/TreeView/TreeView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ describe('<TreeView />', () => {
expect(getByTestId('two')).to.have.focus;
});

it('should support conditional rendered tree items', () => {
function TestComponent() {
const [hide, setState] = React.useState(false);

return (
<React.Fragment>
<button type="button" onClick={() => setState(true)}>
Hide
</button>
<TreeView>{!hide && <TreeItem nodeId="test" label="test" />}</TreeView>
</React.Fragment>
);
}

const { getByText, queryByText } = render(<TestComponent />);

expect(getByText('test')).to.not.be.null;
fireEvent.click(getByText('Hide'));
expect(queryByText('test')).to.be.null;
});

describe('onNodeToggle', () => {
it('should be called when a parent node is clicked', () => {
const handleNodeToggle = spy();
Expand Down

0 comments on commit f430c97

Please sign in to comment.