Skip to content

Commit

Permalink
[core] Use describe TreeView for keyboard selection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed May 17, 2024
1 parent 31511a0 commit 18213bb
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 637 deletions.
19 changes: 0 additions & 19 deletions packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,6 @@ describe('<SimpleTreeView />', () => {
expect(handleTreeItemKeyDown.callCount).to.equal(3);
});

it('should select item when Enter key is pressed ', () => {
const handleKeyDown = spy();

const { getByTestId } = render(
<SimpleTreeView onKeyDown={handleKeyDown}>
<TreeItem itemId="one" data-testid="one" />
</SimpleTreeView>,
);
act(() => {
getByTestId('one').focus();
});

expect(getByTestId('one')).not.to.have.attribute('aria-selected');

fireEvent.keyDown(getByTestId('one'), { key: 'Enter' });

expect(getByTestId('one')).to.have.attribute('aria-selected');
});

it('should not error when component state changes', () => {
function MyComponent() {
const [, setState] = React.useState(1);
Expand Down
Loading

0 comments on commit 18213bb

Please sign in to comment.