Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 17, 2019
1 parent c1cfe02 commit 124f4cf
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/material-ui-lab/src/TreeItem/TreeItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import { spy } from 'sinon';
import { createMount, getClasses } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
import { createClientRender, fireEvent } from 'test/utils/createClientRender';
import { createEvent, createClientRender, fireEvent } from 'test/utils/createClientRender';
import TreeItem from './TreeItem';
import TreeView from '../TreeView';

Expand Down Expand Up @@ -647,4 +647,29 @@ describe('<TreeItem />', () => {
});
});
});

it('should be able to type in an child input', () => {
const { getByRole } = render(
<TreeView defaultExpanded={['one']}>
<TreeItem nodeId="one" label="one" data-testid="one">
<TreeItem
nodeId="two"
label={
<div>
<input type="text" />
</div>
}
data-testid="two"
/>
</TreeItem>
</TreeView>,
);
const input = getByRole('textbox');
const keydownEvent = createEvent.keyDown(input, {
key: 'a',
});
keydownEvent.preventDefault = spy();
fireEvent(input, keydownEvent);
expect(keydownEvent.preventDefault.callCount).to.equal(0);
});
});

0 comments on commit 124f4cf

Please sign in to comment.