| 265 | |
| 266 | it('exposes isCurrentAncestor (render prop + data-current-ancestor) for every ancestor of the current item, regardless of expanded state', async () => { |
| 267 | function Example(props: Partial<NavigationTreeProps<unknown>>) { |
| 268 | return ( |
| 269 | <NavigationTree aria-label="s" {...props}> |
| 270 | <NavigationTreeItem id="libraries" href="/libraries" textValue="Your libraries"> |
| 271 | <NavigationTreeItemContent> |
| 272 | {({isCurrentAncestor}) => ( |
| 273 | <> |
| 274 | <Link>Your libraries</Link> |
| 275 | <Button slot="chevron" aria-label="expand"> |
| 276 | ▶ |
| 277 | </Button> |
| 278 | <span data-testid="anc">{String(isCurrentAncestor)}</span> |
| 279 | </> |
| 280 | )} |
| 281 | </NavigationTreeItemContent> |
| 282 | <NavigationTreeItem id="projects-1" href="/projects-1" textValue="Projects 1"> |
| 283 | <NavigationTreeItemContent> |
| 284 | <Link>Projects 1</Link> |
| 285 | </NavigationTreeItemContent> |
| 286 | </NavigationTreeItem> |
| 287 | </NavigationTreeItem> |
| 288 | </NavigationTree> |
| 289 | ); |
| 290 | } |
| 291 | // Collapsed parent whose descendant is current. |
| 292 | let {getByTestId, getByRole, unmount} = render(<Example selectedRoute="/projects-1" />); |
| 293 | expect(getByTestId('anc')).toHaveTextContent('true'); |