From d09bca0353c1acfcbc8502907397313fc86d1150 Mon Sep 17 00:00:00 2001 From: Dante291 Date: Wed, 22 Nov 2023 11:05:00 +0530 Subject: [PATCH] fixing test --- test/helpers/test_helpers.dart | 65 ++----------------- .../naviagtion_service_test.dart | 1 - 2 files changed, 4 insertions(+), 62 deletions(-) diff --git a/test/helpers/test_helpers.dart b/test/helpers/test_helpers.dart index 32c6d5f72..55e967133 100644 --- a/test/helpers/test_helpers.dart +++ b/test/helpers/test_helpers.dart @@ -120,69 +120,12 @@ void _removeRegistrationIfExists() { NavigationService getAndRegisterNavigationService() { _removeRegistrationIfExists(); final service = MockNavigationService(); - when(service.navigatorKey).thenReturn(GlobalKey()); - - when(service.pushScreen(any, arguments: anyNamed('arguments'))).thenAnswer( - (invocation) => Future.value( - service.navigatorKey.currentState?.pushNamed( - invocation.positionalArguments[0] as String, - arguments: invocation.namedArguments[#arguments], - ), - ), - ); - when(service.popAndPushScreen(any, arguments: anyNamed('arguments'))) - .thenAnswer((invocation) { - service.navigatorKey.currentState?.pop(); - return Future.value( - service.navigatorKey.currentState?.pushNamed( - invocation.positionalArguments[0] as String, - arguments: invocation.namedArguments[#arguments], - ), - ); - }); - when(service.fromInviteLink(any, any)).thenAnswer((invocation) { - final List routeNames = - invocation.positionalArguments[0] as List; - final List arguments = - invocation.positionalArguments[1] as List; - - if (routeNames.isNotEmpty) { - service.navigatorKey.currentState?.pushNamedAndRemoveUntil( - '/${routeNames[0]}', - ModalRoute.withName('/'), - arguments: arguments[0], - ); - for (int i = 1; i < routeNames.length; i++) { - service.navigatorKey.currentState - ?.pushNamed('/${routeNames[i]}', arguments: arguments[i]); - } - } - }); - when(service.pushReplacementScreen(any, arguments: anyNamed('arguments'))) - .thenAnswer( - (invocation) => Future.value( - service.navigatorKey.currentState?.pushReplacementNamed( - invocation.positionalArguments[0] as String, - arguments: invocation.namedArguments[#arguments], - ), - ), - ); when(service.removeAllAndPush(any, any, arguments: anyNamed('arguments'))) - .thenAnswer( - (invocation) => Future.value( - service.navigatorKey.currentState?.pushNamedAndRemoveUntil( - invocation.positionalArguments[0] as String, - ModalRoute.withName(invocation.positionalArguments[1] as String), - arguments: invocation.namedArguments[#arguments], - ), - ), - ); - when(service.pushDialog(any)).thenReturn(null); - when(service.showSnackBar(any)).thenReturn(null); - when(service.showTalawaErrorSnackBar(any, any)).thenReturn(null); - when(service.showTalawaErrorDialog(any, any)).thenReturn(null); - + .thenAnswer((_) async {}); + when(service.pushScreen(any, arguments: anyNamed('arguments'))) + .thenAnswer((_) async {}); + when(service.popAndPushScreen(any, arguments: '-1')).thenAnswer((_) async {}); locator.registerSingleton(service); return service; } diff --git a/test/service_tests/naviagtion_service_test.dart b/test/service_tests/naviagtion_service_test.dart index 548bffa4a..ccc821744 100644 --- a/test/service_tests/naviagtion_service_test.dart +++ b/test/service_tests/naviagtion_service_test.dart @@ -183,7 +183,6 @@ void main() { home: Builder( builder: (BuildContext context) { final currentContext = navigatorKey.currentContext; - print(currentContext); return Scaffold( body: ElevatedButton( onPressed: () {