From 232b2b8505ae59b8b845cb09b626e202c878c752 Mon Sep 17 00:00:00 2001 From: up2up Date: Wed, 13 Jan 2021 13:58:06 +0700 Subject: [PATCH] Fix unit tests --- lib/src/services/auth_service.dart | 4 +++- test/services/auth_service_test.dart | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/src/services/auth_service.dart b/lib/src/services/auth_service.dart index bd3cd837..8e2fe05f 100644 --- a/lib/src/services/auth_service.dart +++ b/lib/src/services/auth_service.dart @@ -11,7 +11,9 @@ class AuthService extends GetxService { final currentUser = UserModel().obs; - AuthService({this.httpService, this.appDirectory}); + AuthService({this.httpService, this.appDirectory}) + : assert(httpService != null), + assert(appDirectory != null); Future login({ String username, diff --git a/test/services/auth_service_test.dart b/test/services/auth_service_test.dart index bdcec7e9..8f00751c 100644 --- a/test/services/auth_service_test.dart +++ b/test/services/auth_service_test.dart @@ -4,9 +4,12 @@ import 'package:matcher/matcher.dart'; import 'package:mockito/mockito.dart'; import 'package:vocadb_app/models.dart'; import 'package:vocadb_app/services.dart'; +import 'package:vocadb_app/utils.dart'; class MockHttpService extends Mock implements HttpService {} +class MockAppDirectory extends Mock implements AppDirectory {} + void main() { group('assertion', () { test('should assert if null', () { @@ -19,7 +22,9 @@ void main() { group('login', () { final mockHttpService = MockHttpService(); - final mockAuthService = AuthService(httpService: mockHttpService); + final mockAppDirectory = MockAppDirectory(); + final mockAuthService = AuthService( + httpService: mockHttpService, appDirectory: mockAppDirectory); test('should return user cookie', () async { final UserCookie mockUserCookie = UserCookie(cookies: []); @@ -34,7 +39,9 @@ void main() { group('getCurrent', () { final mockHttpService = MockHttpService(); - final mockAuthService = AuthService(httpService: mockHttpService); + final mockAppDirectory = MockAppDirectory(); + final mockAuthService = AuthService( + httpService: mockHttpService, appDirectory: mockAppDirectory); test('should return current user', () async { UserModel mockUser = UserModel.fromJson({"id": 1, "name": "up2up"});