Skip to content

Commit

Permalink
test: navigation item calls onTap when an item is tapped off center
Browse files Browse the repository at this point in the history
  • Loading branch information
DE7924 committed Nov 15, 2024
1 parent 56e4433 commit 4e2a93f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/src/components/navigation_bar/navigation_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,29 @@ void main() {
expect(tappedIndex, 3);
});

testWidgets('calls onTap when an item is tapped off center', (WidgetTester tester) async {
var tappedIndex = -1;
await tester.pumpWidget(
TestApp(
home: ZetaNavigationBar(
items: items,
onTap: (index) => tappedIndex = index,
),
),
);

final itemFinder = find.byType(NavigationItem).first;
final offset = tester.getSize(itemFinder).width / 4;

await tester.tapAt(tester.getCenter(itemFinder) + Offset(offset, 0));
expect(tappedIndex, 0);

final lastItemFinder = find.byType(NavigationItem).last;

await tester.tapAt(tester.getCenter(lastItemFinder) + Offset(-offset, 0));
expect(tappedIndex, 3);
});

testWidgets('updates the selected item when an item is tapped', (WidgetTester tester) async {
var selectedIndex = -1;
await tester.pumpWidget(
Expand Down

0 comments on commit 4e2a93f

Please sign in to comment.