import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:yimaru_app/app/app.locator.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:yimaru_app/services/authentication_service.dart'; import 'package:yimaru_app/services/api_service.dart'; import 'package:yimaru_app/services/secure_storage_service.dart'; import 'package:yimaru_app/services/dio_service.dart'; // @stacked-import import 'test_helpers.mocks.dart'; @GenerateMocks( [], customMocks: [ MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), MockSpec(onMissingStub: OnMissingStub.returnDefault), // @stacked-mock-spec ], ) void registerServices() { getAndRegisterNavigationService(); getAndRegisterBottomSheetService(); getAndRegisterDialogService(); getAndRegisterAuthenticationService(); getAndRegisterApiService(); getAndRegisterSecureStorageService(); getAndRegisterDioService(); // @stacked-mock-register } MockNavigationService getAndRegisterNavigationService() { _removeRegistrationIfExists(); final service = MockNavigationService(); locator.registerSingleton(service); return service; } MockBottomSheetService getAndRegisterBottomSheetService({ SheetResponse? showCustomSheetResponse, }) { _removeRegistrationIfExists(); final service = MockBottomSheetService(); when( service.showCustomSheet( enableDrag: anyNamed('enableDrag'), enterBottomSheetDuration: anyNamed('enterBottomSheetDuration'), exitBottomSheetDuration: anyNamed('exitBottomSheetDuration'), ignoreSafeArea: anyNamed('ignoreSafeArea'), isScrollControlled: anyNamed('isScrollControlled'), barrierDismissible: anyNamed('barrierDismissible'), additionalButtonTitle: anyNamed('additionalButtonTitle'), variant: anyNamed('variant'), title: anyNamed('title'), hasImage: anyNamed('hasImage'), imageUrl: anyNamed('imageUrl'), showIconInMainButton: anyNamed('showIconInMainButton'), mainButtonTitle: anyNamed('mainButtonTitle'), showIconInSecondaryButton: anyNamed('showIconInSecondaryButton'), secondaryButtonTitle: anyNamed('secondaryButtonTitle'), showIconInAdditionalButton: anyNamed('showIconInAdditionalButton'), takesInput: anyNamed('takesInput'), barrierColor: anyNamed('barrierColor'), barrierLabel: anyNamed('barrierLabel'), customData: anyNamed('customData'), data: anyNamed('data'), description: anyNamed('description'), ), ).thenAnswer( (realInvocation) => Future.value(showCustomSheetResponse ?? SheetResponse()), ); locator.registerSingleton(service); return service; } MockDialogService getAndRegisterDialogService() { _removeRegistrationIfExists(); final service = MockDialogService(); locator.registerSingleton(service); return service; } MockAuthenticationService getAndRegisterAuthenticationService() { _removeRegistrationIfExists(); final service = MockAuthenticationService(); locator.registerSingleton(service); return service; } MockApiService getAndRegisterApiService() { _removeRegistrationIfExists(); final service = MockApiService(); locator.registerSingleton(service); return service; } MockSecureStorageService getAndRegisterSecureStorageService() { _removeRegistrationIfExists(); final service = MockSecureStorageService(); locator.registerSingleton(service); return service; } MockDioService getAndRegisterDioService() { _removeRegistrationIfExists(); final service = MockDioService(); locator.registerSingleton(service); return service; } // @stacked-mock-create void _removeRegistrationIfExists() { if (locator.isRegistered()) { locator.unregister(); } }