From 4e2a93fec5ab5227af6789d862e6b7c7a8bd9095 Mon Sep 17 00:00:00 2001 From: Daniel Eshkeri Date: Fri, 15 Nov 2024 15:43:05 +0000 Subject: [PATCH] test: navigation item calls onTap when an item is tapped off center --- .../navigation_bar/navigation_bar_test.dart | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/src/components/navigation_bar/navigation_bar_test.dart b/test/src/components/navigation_bar/navigation_bar_test.dart index 952f2ac2..ffbe5e62 100644 --- a/test/src/components/navigation_bar/navigation_bar_test.dart +++ b/test/src/components/navigation_bar/navigation_bar_test.dart @@ -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(