Skip to content

Commit

Permalink
Add to migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Apr 23, 2024
1 parent ce54e89 commit e69e2bb
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,12 @@ For example, if you were writing a test with `react-testing-library`, here is wh
it('test example on first item', () => {
const { getByRole } = render(
<SimpleTreeView>
<TreeItem itemId="one">One</TreeItem>
<TreeItem itemId="two">Two</TreeItem>
<TreeItem itemId="one" id="one">One</TreeItem>
<TreeItem itemId="two" id="two">Two</TreeItem>
</SimpleTreeView>
);

// Set the focus to the item "One"
- const tree = getByRole('tree');
+ const treeItem = getByRole('treeitem', { name: 'One' });
act(() => {
Expand All @@ -429,6 +431,10 @@ For example, if you were writing a test with `react-testing-library`, here is wh
});
- fireEvent.keyDown(tree, { key: 'ArrowDown' });
+ fireEvent.keyDown(treeItem, { key: 'ArrowDown' });

// Check if the new focused item is "Two"
- expect(tree)to.have.attribute('aria-activedescendant', 'two');
+ expect(document.activeElement).to.have.attribute('id', 'two');
})
```

Expand Down

0 comments on commit e69e2bb

Please sign in to comment.