Skip to content

Commit ed21081

Browse files
zigzagdevdyesin
authored andcommitted
test: cover BottomNavigation overflow selector active state
Regression test for the off-by-one bug: with 6 items and activeKey=4 (the first item only reachable via the overflow panel), the "More" tab must be marked aria-selected.
1 parent e466983 commit ed21081

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright (c) Uber Technologies, Inc.
3+
4+
This source code is licensed under the MIT license found in the
5+
LICENSE file in the root directory of this source tree.
6+
*/
7+
import * as React from 'react';
8+
import { render } from '@testing-library/react';
9+
import '@testing-library/jest-dom';
10+
11+
import { BottomNavigation, NavItem } from '..';
12+
import { Overflow } from '../../icon';
13+
14+
describe('BottomNavigation', () => {
15+
it('highlights the overflow selector when the active item is only reachable via More', () => {
16+
const items = Array.from({ length: 6 }).map((_, idx) => (
17+
<NavItem key={idx} title={`Item ${idx}`} icon={Overflow}>
18+
{`panel ${idx}`}
19+
</NavItem>
20+
));
21+
22+
const { getByText } = render(<BottomNavigation activeKey={4}>{items}</BottomNavigation>);
23+
24+
// Item 4 only renders inside the overflow panel/selector (the first 4 items get
25+
// direct selectors), so its being active must highlight the "More" tab.
26+
const moreTab = getByText('More').closest('[role="tab"]');
27+
expect(moreTab).toHaveAttribute('aria-selected', 'true');
28+
});
29+
});

0 commit comments

Comments
 (0)