From 3aff2fa93f2c8a3bad99e5f0b4f8907de769d5f3 Mon Sep 17 00:00:00 2001 From: droidbg Date: Mon, 2 Oct 2023 19:27:12 +0530 Subject: [PATCH 1/3] [Binni] Fix. authentication repository TCs (#46) --- .../data/repository/authentication_repository_test.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/features/auth/data/repository/authentication_repository_test.dart b/test/features/auth/data/repository/authentication_repository_test.dart index b4b0ede4..45aa98ea 100644 --- a/test/features/auth/data/repository/authentication_repository_test.dart +++ b/test/features/auth/data/repository/authentication_repository_test.dart @@ -1,6 +1,7 @@ import 'package:dairy_app/core/errors/database_exceptions.dart'; import 'package:dairy_app/core/network/network_info.dart'; import 'package:dairy_app/features/auth/core/failures/failures.dart'; +import 'package:dairy_app/features/auth/core/validators/email_validator.dart'; import 'package:dairy_app/features/auth/core/validators/password_validator.dart'; import 'package:dairy_app/features/auth/data/datasources/local%20data%20sources/local_data_source_template.dart'; import 'package:dairy_app/features/auth/data/datasources/remote%20data%20sources/remote_data_source_template.dart'; @@ -35,6 +36,7 @@ void main() { localDataSource: localDataSource, networkInfo: networkInfo, passwordValidator: PasswordValidator(), + emailValidator: EmailValidator(), ); }); @@ -166,11 +168,15 @@ void main() { 'should return SignInFailure.passwordDoesNotExists when local data source throws same failure', () async { // arrange + when(networkInfo.isConnected).thenAnswer((_) async => true); when( localDataSource.signInUser( email: anyNamed("email"), password: anyNamed("password")), ).thenThrow(SignInFailure.wrongPassword()); - + when( + remoteDataSource.signInUser( + email: anyNamed("email"), password: anyNamed("password")), + ).thenThrow(FirebaseAuthException(code: 'wrong-password')); // act var result = await authenticationRepository.signInWithEmailAndPassword( email: testEmail, password: testPassword); From f8b14dd7d14ce0b6796c8a4e1f533cee4da37745 Mon Sep 17 00:00:00 2001 From: droidbg Date: Mon, 2 Oct 2023 19:31:41 +0530 Subject: [PATCH 2/3] [Binni] Fix. auth form TCs (#46) --- .../authentication_repository_test.mocks.dart | 291 ++++++- ...in_with_email_and_password_test.mocks.dart | 219 ++++- ...up_with_email_and_password_test.mocks.dart | 229 ++++- .../bloc/auth_form/auth_form_test.dart | 22 +- .../bloc/auth_form/auth_form_test.mocks.dart | 800 +++++++++++++++--- 5 files changed, 1344 insertions(+), 217 deletions(-) diff --git a/test/features/auth/data/repository/authentication_repository_test.mocks.dart b/test/features/auth/data/repository/authentication_repository_test.mocks.dart index 333fb886..71101cd7 100644 --- a/test/features/auth/data/repository/authentication_repository_test.mocks.dart +++ b/test/features/auth/data/repository/authentication_repository_test.mocks.dart @@ -1,7 +1,8 @@ -// Mocks generated by Mockito 5.1.0 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in dairy_app/test/features/auth/data/repository/authentication_repository_test.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i4; import 'package:dairy_app/core/network/network_info.dart' as _i6; @@ -22,9 +23,18 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeLoggedInUserModel_0 extends _i1.Fake - implements _i2.LoggedInUserModel {} +class _FakeLoggedInUserModel_0 extends _i1.SmartFake + implements _i2.LoggedInUserModel { + _FakeLoggedInUserModel_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [IAuthLocalDataSource]. /// @@ -36,30 +46,152 @@ class MockIAuthLocalDataSource extends _i1.Mock } @override - _i4.Future<_i2.LoggedInUserModel> signUpUser( - {dynamic id, String? email, String? password}) => + _i4.Future<_i2.LoggedInUserModel> signUpUser({ + required dynamic id, + required String? email, + required String? password, + }) => (super.noSuchMethod( + Invocation.method( + #signUpUser, + [], + { + #id: id, + #email: email, + #password: password, + }, + ), + returnValue: + _i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0( + this, Invocation.method( - #signUpUser, [], {#id: id, #email: email, #password: password}), - returnValue: Future<_i2.LoggedInUserModel>.value( - _FakeLoggedInUserModel_0())) as _i4 - .Future<_i2.LoggedInUserModel>); + #signUpUser, + [], + { + #id: id, + #email: email, + #password: password, + }, + ), + )), + ) as _i4.Future<_i2.LoggedInUserModel>); @override - _i4.Future<_i2.LoggedInUserModel> signInUser( - {String? email, String? password}) => + _i4.Future<_i2.LoggedInUserModel> signInUser({ + required String? email, + required String? password, + }) => (super.noSuchMethod( - Invocation.method( - #signInUser, [], {#email: email, #password: password}), - returnValue: Future<_i2.LoggedInUserModel>.value( - _FakeLoggedInUserModel_0())) - as _i4.Future<_i2.LoggedInUserModel>); + Invocation.method( + #signInUser, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: + _i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0( + this, + Invocation.method( + #signInUser, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i4.Future<_i2.LoggedInUserModel>); @override - _i4.Future cacheUser({dynamic id, String? email, String? password}) => + _i4.Future cacheUser({ + required dynamic id, + required String? email, + required String? password, + }) => (super.noSuchMethod( + Invocation.method( + #cacheUser, + [], + { + #id: id, + #email: email, + #password: password, + }, + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future verifyPassword( + String? userId, + String? password, + ) => + (super.noSuchMethod( + Invocation.method( + #verifyPassword, + [ + userId, + password, + ], + ), + returnValue: _i4.Future.value(false), + ) as _i4.Future); + @override + _i4.Future updatePassword({ + required String? email, + required String? oldPassword, + required String? newPassword, + }) => + (super.noSuchMethod( + Invocation.method( + #updatePassword, + [], + { + #email: email, + #oldPassword: oldPassword, + #newPassword: newPassword, + }, + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future<_i2.LoggedInUserModel> signInDirectly({required String? userId}) => + (super.noSuchMethod( + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + returnValue: + _i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0( + this, Invocation.method( - #cacheUser, [], {#id: id, #email: email, #password: password}), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i4.Future); + #signInDirectly, + [], + {#userId: userId}, + ), + )), + ) as _i4.Future<_i2.LoggedInUserModel>); + @override + _i4.Future updateEmail({ + required String? oldEmail, + required String? password, + required String? newEmail, + }) => + (super.noSuchMethod( + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); } /// A class which mocks [IAuthRemoteDataSource]. @@ -72,23 +204,107 @@ class MockIAuthRemoteDataSource extends _i1.Mock } @override - _i4.Future<_i2.LoggedInUserModel> signUpUser( - {String? email, String? password}) => + _i4.Future<_i2.LoggedInUserModel> signUpUser({ + required String? email, + required String? password, + }) => + (super.noSuchMethod( + Invocation.method( + #signUpUser, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: + _i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0( + this, + Invocation.method( + #signUpUser, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i4.Future<_i2.LoggedInUserModel>); + @override + _i4.Future<_i2.LoggedInUserModel> signInUser({ + required String? email, + required String? password, + }) => + (super.noSuchMethod( + Invocation.method( + #signInUser, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: + _i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0( + this, + Invocation.method( + #signInUser, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i4.Future<_i2.LoggedInUserModel>); + @override + _i4.Future updatePassword({ + required String? email, + required String? oldPassword, + required String? newPassword, + }) => + (super.noSuchMethod( + Invocation.method( + #updatePassword, + [], + { + #email: email, + #oldPassword: oldPassword, + #newPassword: newPassword, + }, + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override + _i4.Future submitForgotPasswordEmail(String? forgotPasswordEmail) => (super.noSuchMethod( - Invocation.method( - #signUpUser, [], {#email: email, #password: password}), - returnValue: Future<_i2.LoggedInUserModel>.value( - _FakeLoggedInUserModel_0())) - as _i4.Future<_i2.LoggedInUserModel>); + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); @override - _i4.Future<_i2.LoggedInUserModel> signInUser( - {String? email, String? password}) => + _i4.Future updateEmail({ + required String? oldEmail, + required String? password, + required String? newEmail, + }) => (super.noSuchMethod( - Invocation.method( - #signInUser, [], {#email: email, #password: password}), - returnValue: Future<_i2.LoggedInUserModel>.value( - _FakeLoggedInUserModel_0())) - as _i4.Future<_i2.LoggedInUserModel>); + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); } /// A class which mocks [INetworkInfo]. @@ -100,7 +316,8 @@ class MockINetworkInfo extends _i1.Mock implements _i6.INetworkInfo { } @override - _i4.Future get isConnected => - (super.noSuchMethod(Invocation.getter(#isConnected), - returnValue: Future.value(false)) as _i4.Future); + _i4.Future get isConnected => (super.noSuchMethod( + Invocation.getter(#isConnected), + returnValue: _i4.Future.value(false), + ) as _i4.Future); } diff --git a/test/features/auth/domain/usecases/sign_in_with_email_and_password_test.mocks.dart b/test/features/auth/domain/usecases/sign_in_with_email_and_password_test.mocks.dart index 0f3dc1e8..1d625c80 100644 --- a/test/features/auth/domain/usecases/sign_in_with_email_and_password_test.mocks.dart +++ b/test/features/auth/domain/usecases/sign_in_with_email_and_password_test.mocks.dart @@ -1,7 +1,8 @@ -// Mocks generated by Mockito 5.1.0 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in dairy_app/test/features/auth/domain/usecases/sign_in_with_email_and_password_test.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i5; import 'package:dairy_app/features/auth/core/failures/failures.dart' as _i6; @@ -23,8 +24,17 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeEither_0 extends _i1.Fake implements _i2.Either {} +class _FakeEither_0 extends _i1.SmartFake implements _i2.Either { + _FakeEither_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [EmailValidator]. /// @@ -35,9 +45,13 @@ class MockEmailValidator extends _i1.Mock implements _i3.EmailValidator { } @override - bool call(String? email) => - (super.noSuchMethod(Invocation.method(#call, [email]), returnValue: false) - as bool); + bool call(String? email) => (super.noSuchMethod( + Invocation.method( + #call, + [email], + ), + returnValue: false, + ) as bool); } /// A class which mocks [IAuthenticationRepository]. @@ -51,22 +65,189 @@ class MockIAuthenticationRepository extends _i1.Mock @override _i5.Future<_i2.Either<_i6.SignUpFailure, _i7.LoggedInUser>> - signUpWithEmailAndPassword({String? email, String? password}) => + signUpWithEmailAndPassword({ + required String? email, + required String? password, + }) => (super.noSuchMethod( - Invocation.method(#signUpWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i2.Either<_i6.SignUpFailure, _i7.LoggedInUser>>.value( - _FakeEither_0<_i6.SignUpFailure, _i7.LoggedInUser>())) as _i5 - .Future<_i2.Either<_i6.SignUpFailure, _i7.LoggedInUser>>); + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i5 + .Future<_i2.Either<_i6.SignUpFailure, _i7.LoggedInUser>>.value( + _FakeEither_0<_i6.SignUpFailure, _i7.LoggedInUser>( + this, + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i5.Future<_i2.Either<_i6.SignUpFailure, _i7.LoggedInUser>>); @override _i5.Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>> - signInWithEmailAndPassword({String? email, String? password}) => + signInWithEmailAndPassword({ + required String? email, + required String? password, + }) => (super.noSuchMethod( - Invocation.method(#signInWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>.value( - _FakeEither_0<_i6.SignInFailure, _i7.LoggedInUser>())) as _i5 - .Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>); + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i5 + .Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>.value( + _FakeEither_0<_i6.SignInFailure, _i7.LoggedInUser>( + this, + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i5.Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>); + @override + _i5.Future verifyPassword( + String? userId, + String? password, + ) => + (super.noSuchMethod( + Invocation.method( + #verifyPassword, + [ + userId, + password, + ], + ), + returnValue: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future<_i2.Either<_i6.SignUpFailure, bool>> updatePassword( + String? email, + String? oldPassword, + String? newPassword, + ) => + (super.noSuchMethod( + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + returnValue: _i5.Future<_i2.Either<_i6.SignUpFailure, bool>>.value( + _FakeEither_0<_i6.SignUpFailure, bool>( + this, + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + )), + ) as _i5.Future<_i2.Either<_i6.SignUpFailure, bool>>); + @override + _i5.Future isFingerprintAuthPossible() => (super.noSuchMethod( + Invocation.method( + #isFingerprintAuthPossible, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Stream<_i4.FingerPrintAuthState> processFingerPrintAuth() => + (super.noSuchMethod( + Invocation.method( + #processFingerPrintAuth, + [], + ), + returnValue: _i5.Stream<_i4.FingerPrintAuthState>.empty(), + ) as _i5.Stream<_i4.FingerPrintAuthState>); + @override + _i5.Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>> signInDirectly( + {required String? userId}) => + (super.noSuchMethod( + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + returnValue: + _i5.Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>.value( + _FakeEither_0<_i6.SignInFailure, _i7.LoggedInUser>( + this, + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + )), + ) as _i5.Future<_i2.Either<_i6.SignInFailure, _i7.LoggedInUser>>); + @override + _i5.Future<_i2.Either<_i6.ForgotPasswordFailure, bool>> + submitForgotPasswordEmail(String? forgotPasswordEmail) => + (super.noSuchMethod( + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + returnValue: + _i5.Future<_i2.Either<_i6.ForgotPasswordFailure, bool>>.value( + _FakeEither_0<_i6.ForgotPasswordFailure, bool>( + this, + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + )), + ) as _i5.Future<_i2.Either<_i6.ForgotPasswordFailure, bool>>); + @override + _i5.Future<_i2.Either<_i6.SignUpFailure, bool>> updateEmail({ + required String? oldEmail, + required String? password, + required String? newEmail, + }) => + (super.noSuchMethod( + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + returnValue: _i5.Future<_i2.Either<_i6.SignUpFailure, bool>>.value( + _FakeEither_0<_i6.SignUpFailure, bool>( + this, + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + )), + ) as _i5.Future<_i2.Either<_i6.SignUpFailure, bool>>); } diff --git a/test/features/auth/domain/usecases/sign_up_with_email_and_password_test.mocks.dart b/test/features/auth/domain/usecases/sign_up_with_email_and_password_test.mocks.dart index 59ca185a..68864a63 100644 --- a/test/features/auth/domain/usecases/sign_up_with_email_and_password_test.mocks.dart +++ b/test/features/auth/domain/usecases/sign_up_with_email_and_password_test.mocks.dart @@ -1,7 +1,8 @@ -// Mocks generated by Mockito 5.1.0 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in dairy_app/test/features/auth/domain/usecases/sign_up_with_email_and_password_test.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i6; import 'package:dairy_app/features/auth/core/failures/failures.dart' as _i7; @@ -25,8 +26,17 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeEither_0 extends _i1.Fake implements _i2.Either {} +class _FakeEither_0 extends _i1.SmartFake implements _i2.Either { + _FakeEither_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [EmailValidator]. /// @@ -37,9 +47,13 @@ class MockEmailValidator extends _i1.Mock implements _i3.EmailValidator { } @override - bool call(String? email) => - (super.noSuchMethod(Invocation.method(#call, [email]), returnValue: false) - as bool); + bool call(String? email) => (super.noSuchMethod( + Invocation.method( + #call, + [email], + ), + returnValue: false, + ) as bool); } /// A class which mocks [PasswordValidator]. @@ -51,9 +65,13 @@ class MockPasswordValidator extends _i1.Mock implements _i4.PasswordValidator { } @override - bool call(String? password) => - (super.noSuchMethod(Invocation.method(#call, [password]), - returnValue: false) as bool); + bool call(String? password) => (super.noSuchMethod( + Invocation.method( + #call, + [password], + ), + returnValue: false, + ) as bool); } /// A class which mocks [IAuthenticationRepository]. @@ -67,22 +85,189 @@ class MockIAuthenticationRepository extends _i1.Mock @override _i6.Future<_i2.Either<_i7.SignUpFailure, _i8.LoggedInUser>> - signUpWithEmailAndPassword({String? email, String? password}) => + signUpWithEmailAndPassword({ + required String? email, + required String? password, + }) => (super.noSuchMethod( - Invocation.method(#signUpWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i2.Either<_i7.SignUpFailure, _i8.LoggedInUser>>.value( - _FakeEither_0<_i7.SignUpFailure, _i8.LoggedInUser>())) as _i6 - .Future<_i2.Either<_i7.SignUpFailure, _i8.LoggedInUser>>); + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i6 + .Future<_i2.Either<_i7.SignUpFailure, _i8.LoggedInUser>>.value( + _FakeEither_0<_i7.SignUpFailure, _i8.LoggedInUser>( + this, + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i6.Future<_i2.Either<_i7.SignUpFailure, _i8.LoggedInUser>>); @override _i6.Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>> - signInWithEmailAndPassword({String? email, String? password}) => + signInWithEmailAndPassword({ + required String? email, + required String? password, + }) => (super.noSuchMethod( - Invocation.method(#signInWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>.value( - _FakeEither_0<_i7.SignInFailure, _i8.LoggedInUser>())) as _i6 - .Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>); + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i6 + .Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>.value( + _FakeEither_0<_i7.SignInFailure, _i8.LoggedInUser>( + this, + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i6.Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>); + @override + _i6.Future verifyPassword( + String? userId, + String? password, + ) => + (super.noSuchMethod( + Invocation.method( + #verifyPassword, + [ + userId, + password, + ], + ), + returnValue: _i6.Future.value(false), + ) as _i6.Future); + @override + _i6.Future<_i2.Either<_i7.SignUpFailure, bool>> updatePassword( + String? email, + String? oldPassword, + String? newPassword, + ) => + (super.noSuchMethod( + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + returnValue: _i6.Future<_i2.Either<_i7.SignUpFailure, bool>>.value( + _FakeEither_0<_i7.SignUpFailure, bool>( + this, + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + )), + ) as _i6.Future<_i2.Either<_i7.SignUpFailure, bool>>); + @override + _i6.Future isFingerprintAuthPossible() => (super.noSuchMethod( + Invocation.method( + #isFingerprintAuthPossible, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Stream<_i5.FingerPrintAuthState> processFingerPrintAuth() => + (super.noSuchMethod( + Invocation.method( + #processFingerPrintAuth, + [], + ), + returnValue: _i6.Stream<_i5.FingerPrintAuthState>.empty(), + ) as _i6.Stream<_i5.FingerPrintAuthState>); + @override + _i6.Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>> signInDirectly( + {required String? userId}) => + (super.noSuchMethod( + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + returnValue: + _i6.Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>.value( + _FakeEither_0<_i7.SignInFailure, _i8.LoggedInUser>( + this, + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + )), + ) as _i6.Future<_i2.Either<_i7.SignInFailure, _i8.LoggedInUser>>); + @override + _i6.Future<_i2.Either<_i7.ForgotPasswordFailure, bool>> + submitForgotPasswordEmail(String? forgotPasswordEmail) => + (super.noSuchMethod( + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + returnValue: + _i6.Future<_i2.Either<_i7.ForgotPasswordFailure, bool>>.value( + _FakeEither_0<_i7.ForgotPasswordFailure, bool>( + this, + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + )), + ) as _i6.Future<_i2.Either<_i7.ForgotPasswordFailure, bool>>); + @override + _i6.Future<_i2.Either<_i7.SignUpFailure, bool>> updateEmail({ + required String? oldEmail, + required String? password, + required String? newEmail, + }) => + (super.noSuchMethod( + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + returnValue: _i6.Future<_i2.Either<_i7.SignUpFailure, bool>>.value( + _FakeEither_0<_i7.SignUpFailure, bool>( + this, + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + )), + ) as _i6.Future<_i2.Either<_i7.SignUpFailure, bool>>); } diff --git a/test/features/auth/presentation/bloc/auth_form/auth_form_test.dart b/test/features/auth/presentation/bloc/auth_form/auth_form_test.dart index 046281f5..e33346fb 100644 --- a/test/features/auth/presentation/bloc/auth_form/auth_form_test.dart +++ b/test/features/auth/presentation/bloc/auth_form/auth_form_test.dart @@ -1,11 +1,13 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:dairy_app/features/auth/core/failures/failures.dart'; import 'package:dairy_app/features/auth/data/repositories/authentication_repository.dart'; +import 'package:dairy_app/features/auth/data/repositories/fingerprint_auth_repo.dart'; import 'package:dairy_app/features/auth/domain/entities/logged_in_user.dart'; import 'package:dairy_app/features/auth/domain/usecases/sign_in_with_email_and_password.dart'; import 'package:dairy_app/features/auth/domain/usecases/sign_up_with_email_and_password.dart'; import 'package:dairy_app/features/auth/presentation/bloc/auth_form/auth_form_bloc.dart'; import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart'; +import 'package:dairy_app/features/sync/data/datasources/key_value_data_source.dart'; import 'package:dartz/dartz.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; @@ -17,13 +19,17 @@ import 'auth_form_test.mocks.dart'; AuthSessionBloc, AuthenticationRepository, SignUpWithEmailAndPassword, - SignInWithEmailAndPassword + SignInWithEmailAndPassword, + KeyValueDataSource, + FingerPrintAuthRepository ]) void main() { late MockAuthenticationRepository authenticationRepository; late MockAuthSessionBloc authSessionBloc; late MockSignUpWithEmailAndPassword signUpWithEmailAndPassword; late MockSignInWithEmailAndPassword signInWithEmailAndPassword; + late MockKeyValueDataSource mockKeyValueDataSource; + late MockFingerPrintAuthRepository mockFingerPrintAuthRepository; late AuthFormBloc authFormBloc; const String testEmail = "test@email"; @@ -36,10 +42,16 @@ void main() { authSessionBloc = MockAuthSessionBloc(); signUpWithEmailAndPassword = MockSignUpWithEmailAndPassword(); signInWithEmailAndPassword = MockSignInWithEmailAndPassword(); + mockKeyValueDataSource = MockKeyValueDataSource(); + mockFingerPrintAuthRepository = MockFingerPrintAuthRepository(); + authFormBloc = AuthFormBloc( authSessionBloc: authSessionBloc, signInWithEmailAndPassword: signInWithEmailAndPassword, signUpWithEmailAndPassword: signUpWithEmailAndPassword, + authenticationRepository: authenticationRepository, + keyValueDataSource: mockKeyValueDataSource, + fingerPrintAuthRepository: mockFingerPrintAuthRepository, ); }); @@ -169,7 +181,7 @@ void main() { act: (bloc) { bloc.add(const AuthFormInputsChangedEvent( email: testEmail, password: testPassword)); - bloc.add(AuthFormSignInSubmitted()); + bloc.add(const AuthFormSignInSubmitted()); }, expect: () => const [ AuthFormInitial(email: testEmail, password: testPassword), @@ -190,7 +202,7 @@ void main() { act: (bloc) { bloc.add(const AuthFormInputsChangedEvent( email: testEmail, password: testPassword)); - bloc.add(AuthFormSignInSubmitted()); + bloc.add(const AuthFormSignInSubmitted()); }, expect: () => [ const AuthFormInitial(email: testEmail, password: testPassword), @@ -200,7 +212,7 @@ void main() { email: testEmail, password: testPassword, errors: { - "email": [SignInFailure.noInternetConnection().message] + "general": [SignInFailure.noInternetConnection().message] }) ], ); @@ -217,7 +229,7 @@ void main() { act: (bloc) { bloc.add(const AuthFormInputsChangedEvent( email: testEmail, password: testPassword)); - bloc.add(AuthFormSignInSubmitted()); + bloc.add(const AuthFormSignInSubmitted()); }, expect: () => [ const AuthFormInitial(email: testEmail, password: testPassword), diff --git a/test/features/auth/presentation/bloc/auth_form/auth_form_test.mocks.dart b/test/features/auth/presentation/bloc/auth_form/auth_form_test.mocks.dart index 2f24b7f2..b28cae5c 100644 --- a/test/features/auth/presentation/bloc/auth_form/auth_form_test.mocks.dart +++ b/test/features/auth/presentation/bloc/auth_form/auth_form_test.mocks.dart @@ -1,33 +1,41 @@ -// Mocks generated by Mockito 5.1.0 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in dairy_app/test/features/auth/presentation/bloc/auth_form/auth_form_test.dart. // Do not manually edit this file. -import 'dart:async' as _i10; +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i12; -import 'package:bloc/bloc.dart' as _i11; -import 'package:dairy_app/core/network/network_info.dart' as _i3; -import 'package:dairy_app/features/auth/core/failures/failures.dart' as _i13; +import 'package:bloc/bloc.dart' as _i13; +import 'package:dairy_app/core/network/network_info.dart' as _i4; +import 'package:dairy_app/features/auth/core/failures/failures.dart' as _i15; import 'package:dairy_app/features/auth/core/validators/email_validator.dart' - as _i7; -import 'package:dairy_app/features/auth/core/validators/password_validator.dart' as _i8; +import 'package:dairy_app/features/auth/core/validators/password_validator.dart' + as _i7; import 'package:dairy_app/features/auth/data/datasources/local%20data%20sources/local_data_source_template.dart' - as _i5; + as _i6; import 'package:dairy_app/features/auth/data/datasources/remote%20data%20sources/remote_data_source_template.dart' - as _i4; + as _i5; import 'package:dairy_app/features/auth/data/repositories/authentication_repository.dart' - as _i12; -import 'package:dairy_app/features/auth/domain/entities/logged_in_user.dart' as _i14; +import 'package:dairy_app/features/auth/data/repositories/fingerprint_auth_repo.dart' + as _i20; +import 'package:dairy_app/features/auth/domain/entities/logged_in_user.dart' + as _i16; import 'package:dairy_app/features/auth/domain/repositories/authentication_repository.dart' - as _i9; + as _i11; import 'package:dairy_app/features/auth/domain/usecases/sign_in_with_email_and_password.dart' - as _i16; + as _i18; import 'package:dairy_app/features/auth/domain/usecases/sign_up_with_email_and_password.dart' - as _i15; + as _i17; import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart' + as _i3; +import 'package:dairy_app/features/sync/data/datasources/key_value_data_source.dart' + as _i19; +import 'package:dairy_app/features/sync/data/datasources/temeplates/key_value_data_source_template.dart' as _i2; -import 'package:dartz/dartz.dart' as _i6; +import 'package:dartz/dartz.dart' as _i10; +import 'package:local_auth/local_auth.dart' as _i9; import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: type=lint @@ -39,193 +47,717 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeAuthSessionState_0 extends _i1.Fake implements _i2.AuthSessionState { +class _FakeIKeyValueDataSource_0 extends _i1.SmartFake + implements _i2.IKeyValueDataSource { + _FakeIKeyValueDataSource_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); } -class _FakeINetworkInfo_1 extends _i1.Fake implements _i3.INetworkInfo {} +class _FakeAuthSessionState_1 extends _i1.SmartFake + implements _i3.AuthSessionState { + _FakeAuthSessionState_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeIAuthRemoteDataSource_2 extends _i1.Fake - implements _i4.IAuthRemoteDataSource {} +class _FakeINetworkInfo_2 extends _i1.SmartFake implements _i4.INetworkInfo { + _FakeINetworkInfo_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeIAuthLocalDataSource_3 extends _i1.Fake - implements _i5.IAuthLocalDataSource {} +class _FakeIAuthRemoteDataSource_3 extends _i1.SmartFake + implements _i5.IAuthRemoteDataSource { + _FakeIAuthRemoteDataSource_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeEither_4 extends _i1.Fake implements _i6.Either {} +class _FakeIAuthLocalDataSource_4 extends _i1.SmartFake + implements _i6.IAuthLocalDataSource { + _FakeIAuthLocalDataSource_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeEmailValidator_5 extends _i1.Fake implements _i7.EmailValidator {} +class _FakePasswordValidator_5 extends _i1.SmartFake + implements _i7.PasswordValidator { + _FakePasswordValidator_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakePasswordValidator_6 extends _i1.Fake - implements _i8.PasswordValidator {} +class _FakeEmailValidator_6 extends _i1.SmartFake + implements _i8.EmailValidator { + _FakeEmailValidator_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeIAuthenticationRepository_7 extends _i1.Fake - implements _i9.IAuthenticationRepository {} +class _FakeLocalAuthentication_7 extends _i1.SmartFake + implements _i9.LocalAuthentication { + _FakeLocalAuthentication_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeEither_8 extends _i1.SmartFake implements _i10.Either { + _FakeEither_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeIAuthenticationRepository_9 extends _i1.SmartFake + implements _i11.IAuthenticationRepository { + _FakeIAuthenticationRepository_9( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeAuthSessionBloc_10 extends _i1.SmartFake + implements _i3.AuthSessionBloc { + _FakeAuthSessionBloc_10( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [AuthSessionBloc]. /// /// See the documentation for Mockito's code generation for more information. -class MockAuthSessionBloc extends _i1.Mock implements _i2.AuthSessionBloc { +class MockAuthSessionBloc extends _i1.Mock implements _i3.AuthSessionBloc { MockAuthSessionBloc() { _i1.throwOnMissingStub(this); } @override - _i2.AuthSessionState get state => - (super.noSuchMethod(Invocation.getter(#state), - returnValue: _FakeAuthSessionState_0()) as _i2.AuthSessionState); + _i2.IKeyValueDataSource get keyValueDataSource => (super.noSuchMethod( + Invocation.getter(#keyValueDataSource), + returnValue: _FakeIKeyValueDataSource_0( + this, + Invocation.getter(#keyValueDataSource), + ), + ) as _i2.IKeyValueDataSource); @override - _i10.Stream<_i2.AuthSessionState> get stream => - (super.noSuchMethod(Invocation.getter(#stream), - returnValue: Stream<_i2.AuthSessionState>.empty()) - as _i10.Stream<_i2.AuthSessionState>); + _i3.AuthSessionState get state => (super.noSuchMethod( + Invocation.getter(#state), + returnValue: _FakeAuthSessionState_1( + this, + Invocation.getter(#state), + ), + ) as _i3.AuthSessionState); @override - bool get isClosed => - (super.noSuchMethod(Invocation.getter(#isClosed), returnValue: false) - as bool); + _i12.Stream<_i3.AuthSessionState> get stream => (super.noSuchMethod( + Invocation.getter(#stream), + returnValue: _i12.Stream<_i3.AuthSessionState>.empty(), + ) as _i12.Stream<_i3.AuthSessionState>); @override - void add(_i2.AuthSessionEvent? event) => - super.noSuchMethod(Invocation.method(#add, [event]), - returnValueForMissingStub: null); + bool get isClosed => (super.noSuchMethod( + Invocation.getter(#isClosed), + returnValue: false, + ) as bool); @override - void onEvent(_i2.AuthSessionEvent? event) => - super.noSuchMethod(Invocation.method(#onEvent, [event]), - returnValueForMissingStub: null); + void add(_i3.AuthSessionEvent? event) => super.noSuchMethod( + Invocation.method( + #add, + [event], + ), + returnValueForMissingStub: null, + ); @override - void emit(_i2.AuthSessionState? state) => - super.noSuchMethod(Invocation.method(#emit, [state]), - returnValueForMissingStub: null); + void onEvent(_i3.AuthSessionEvent? event) => super.noSuchMethod( + Invocation.method( + #onEvent, + [event], + ), + returnValueForMissingStub: null, + ); @override - void on( - _i11.EventHandler? handler, - {_i11.EventTransformer? transformer}) => + void emit(_i3.AuthSessionState? state) => super.noSuchMethod( + Invocation.method( + #emit, + [state], + ), + returnValueForMissingStub: null, + ); + @override + void on( + _i13.EventHandler? handler, { + _i13.EventTransformer? transformer, + }) => super.noSuchMethod( - Invocation.method(#on, [handler], {#transformer: transformer}), - returnValueForMissingStub: null); + Invocation.method( + #on, + [handler], + {#transformer: transformer}, + ), + returnValueForMissingStub: null, + ); @override void onTransition( - _i11.Transition<_i2.AuthSessionEvent, _i2.AuthSessionState>? + _i13.Transition<_i3.AuthSessionEvent, _i3.AuthSessionState>? transition) => - super.noSuchMethod(Invocation.method(#onTransition, [transition]), - returnValueForMissingStub: null); + super.noSuchMethod( + Invocation.method( + #onTransition, + [transition], + ), + returnValueForMissingStub: null, + ); @override - _i10.Future close() => (super.noSuchMethod( - Invocation.method(#close, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i10.Future); + _i12.Future close() => (super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); @override - void onChange(_i11.Change<_i2.AuthSessionState>? change) => - super.noSuchMethod(Invocation.method(#onChange, [change]), - returnValueForMissingStub: null); + void onChange(_i13.Change<_i3.AuthSessionState>? change) => + super.noSuchMethod( + Invocation.method( + #onChange, + [change], + ), + returnValueForMissingStub: null, + ); @override - void addError(Object? error, [StackTrace? stackTrace]) => - super.noSuchMethod(Invocation.method(#addError, [error, stackTrace]), - returnValueForMissingStub: null); + void addError( + Object? error, [ + StackTrace? stackTrace, + ]) => + super.noSuchMethod( + Invocation.method( + #addError, + [ + error, + stackTrace, + ], + ), + returnValueForMissingStub: null, + ); @override - void onError(Object? error, StackTrace? stackTrace) => - super.noSuchMethod(Invocation.method(#onError, [error, stackTrace]), - returnValueForMissingStub: null); + void onError( + Object? error, + StackTrace? stackTrace, + ) => + super.noSuchMethod( + Invocation.method( + #onError, + [ + error, + stackTrace, + ], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [AuthenticationRepository]. /// /// See the documentation for Mockito's code generation for more information. class MockAuthenticationRepository extends _i1.Mock - implements _i12.AuthenticationRepository { + implements _i14.AuthenticationRepository { MockAuthenticationRepository() { _i1.throwOnMissingStub(this); } @override - _i3.INetworkInfo get networkInfo => - (super.noSuchMethod(Invocation.getter(#networkInfo), - returnValue: _FakeINetworkInfo_1()) as _i3.INetworkInfo); - @override - _i4.IAuthRemoteDataSource get remoteDataSource => - (super.noSuchMethod(Invocation.getter(#remoteDataSource), - returnValue: _FakeIAuthRemoteDataSource_2()) - as _i4.IAuthRemoteDataSource); - @override - _i5.IAuthLocalDataSource get localDataSource => (super.noSuchMethod( - Invocation.getter(#localDataSource), - returnValue: _FakeIAuthLocalDataSource_3()) as _i5.IAuthLocalDataSource); - @override - _i10.Future<_i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>> - signUpWithEmailAndPassword({String? email, String? password}) => (super - .noSuchMethod( - Invocation.method(#signUpWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>>.value( - _FakeEither_4<_i13.SignUpFailure, _i14.LoggedInUser>())) - as _i10.Future<_i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>>); - @override - _i10.Future<_i6.Either<_i13.SignInFailure, _i14.LoggedInUser>> - signInWithEmailAndPassword({String? email, String? password}) => (super - .noSuchMethod( - Invocation.method(#signInWithEmailAndPassword, [], - {#email: email, #password: password}), - returnValue: - Future<_i6.Either<_i13.SignInFailure, _i14.LoggedInUser>>.value( - _FakeEither_4<_i13.SignInFailure, _i14.LoggedInUser>())) - as _i10.Future<_i6.Either<_i13.SignInFailure, _i14.LoggedInUser>>); + _i4.INetworkInfo get networkInfo => (super.noSuchMethod( + Invocation.getter(#networkInfo), + returnValue: _FakeINetworkInfo_2( + this, + Invocation.getter(#networkInfo), + ), + ) as _i4.INetworkInfo); + @override + _i5.IAuthRemoteDataSource get remoteDataSource => (super.noSuchMethod( + Invocation.getter(#remoteDataSource), + returnValue: _FakeIAuthRemoteDataSource_3( + this, + Invocation.getter(#remoteDataSource), + ), + ) as _i5.IAuthRemoteDataSource); + @override + _i6.IAuthLocalDataSource get localDataSource => (super.noSuchMethod( + Invocation.getter(#localDataSource), + returnValue: _FakeIAuthLocalDataSource_4( + this, + Invocation.getter(#localDataSource), + ), + ) as _i6.IAuthLocalDataSource); + @override + _i7.PasswordValidator get passwordValidator => (super.noSuchMethod( + Invocation.getter(#passwordValidator), + returnValue: _FakePasswordValidator_5( + this, + Invocation.getter(#passwordValidator), + ), + ) as _i7.PasswordValidator); + @override + _i8.EmailValidator get emailValidator => (super.noSuchMethod( + Invocation.getter(#emailValidator), + returnValue: _FakeEmailValidator_6( + this, + Invocation.getter(#emailValidator), + ), + ) as _i8.EmailValidator); + @override + _i9.LocalAuthentication get auth => (super.noSuchMethod( + Invocation.getter(#auth), + returnValue: _FakeLocalAuthentication_7( + this, + Invocation.getter(#auth), + ), + ) as _i9.LocalAuthentication); + @override + _i12.Future<_i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>> + signUpWithEmailAndPassword({ + required String? email, + required String? password, + }) => + (super.noSuchMethod( + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i12.Future< + _i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>>.value( + _FakeEither_8<_i15.SignUpFailure, _i16.LoggedInUser>( + this, + Invocation.method( + #signUpWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>>); + @override + _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>> + signInWithEmailAndPassword({ + required String? email, + required String? password, + }) => + (super.noSuchMethod( + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + returnValue: _i12.Future< + _i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>.value( + _FakeEither_8<_i15.SignInFailure, _i16.LoggedInUser>( + this, + Invocation.method( + #signInWithEmailAndPassword, + [], + { + #email: email, + #password: password, + }, + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>); + @override + _i12.Future verifyPassword( + String? userId, + String? password, + ) => + (super.noSuchMethod( + Invocation.method( + #verifyPassword, + [ + userId, + password, + ], + ), + returnValue: _i12.Future.value(false), + ) as _i12.Future); + @override + _i12.Future<_i10.Either<_i15.SignUpFailure, bool>> updatePassword( + String? email, + String? oldPassword, + String? newPassword, + ) => + (super.noSuchMethod( + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + returnValue: _i12.Future<_i10.Either<_i15.SignUpFailure, bool>>.value( + _FakeEither_8<_i15.SignUpFailure, bool>( + this, + Invocation.method( + #updatePassword, + [ + email, + oldPassword, + newPassword, + ], + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignUpFailure, bool>>); + @override + _i12.Future isFingerprintAuthPossible() => (super.noSuchMethod( + Invocation.method( + #isFingerprintAuthPossible, + [], + ), + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); + @override + _i12.Stream<_i11.FingerPrintAuthState> processFingerPrintAuth() => + (super.noSuchMethod( + Invocation.method( + #processFingerPrintAuth, + [], + ), + returnValue: _i12.Stream<_i11.FingerPrintAuthState>.empty(), + ) as _i12.Stream<_i11.FingerPrintAuthState>); + @override + _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>> + signInDirectly({required String? userId}) => (super.noSuchMethod( + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + returnValue: _i12.Future< + _i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>.value( + _FakeEither_8<_i15.SignInFailure, _i16.LoggedInUser>( + this, + Invocation.method( + #signInDirectly, + [], + {#userId: userId}, + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>); + @override + _i12.Future<_i10.Either<_i15.ForgotPasswordFailure, bool>> + submitForgotPasswordEmail(String? forgotPasswordEmail) => + (super.noSuchMethod( + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + returnValue: _i12 + .Future<_i10.Either<_i15.ForgotPasswordFailure, bool>>.value( + _FakeEither_8<_i15.ForgotPasswordFailure, bool>( + this, + Invocation.method( + #submitForgotPasswordEmail, + [forgotPasswordEmail], + ), + )), + ) as _i12.Future<_i10.Either<_i15.ForgotPasswordFailure, bool>>); + @override + _i12.Future<_i10.Either<_i15.SignUpFailure, bool>> updateEmail({ + required String? oldEmail, + required String? password, + required String? newEmail, + }) => + (super.noSuchMethod( + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + returnValue: _i12.Future<_i10.Either<_i15.SignUpFailure, bool>>.value( + _FakeEither_8<_i15.SignUpFailure, bool>( + this, + Invocation.method( + #updateEmail, + [], + { + #oldEmail: oldEmail, + #password: password, + #newEmail: newEmail, + }, + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignUpFailure, bool>>); } /// A class which mocks [SignUpWithEmailAndPassword]. /// /// See the documentation for Mockito's code generation for more information. class MockSignUpWithEmailAndPassword extends _i1.Mock - implements _i15.SignUpWithEmailAndPassword { + implements _i17.SignUpWithEmailAndPassword { MockSignUpWithEmailAndPassword() { _i1.throwOnMissingStub(this); } @override - _i7.EmailValidator get emailValidator => - (super.noSuchMethod(Invocation.getter(#emailValidator), - returnValue: _FakeEmailValidator_5()) as _i7.EmailValidator); + _i8.EmailValidator get emailValidator => (super.noSuchMethod( + Invocation.getter(#emailValidator), + returnValue: _FakeEmailValidator_6( + this, + Invocation.getter(#emailValidator), + ), + ) as _i8.EmailValidator); @override - _i8.PasswordValidator get passwordValidator => - (super.noSuchMethod(Invocation.getter(#passwordValidator), - returnValue: _FakePasswordValidator_6()) as _i8.PasswordValidator); + _i7.PasswordValidator get passwordValidator => (super.noSuchMethod( + Invocation.getter(#passwordValidator), + returnValue: _FakePasswordValidator_5( + this, + Invocation.getter(#passwordValidator), + ), + ) as _i7.PasswordValidator); @override - _i9.IAuthenticationRepository get authenticationRepository => - (super.noSuchMethod(Invocation.getter(#authenticationRepository), - returnValue: _FakeIAuthenticationRepository_7()) - as _i9.IAuthenticationRepository); + _i11.IAuthenticationRepository get authenticationRepository => + (super.noSuchMethod( + Invocation.getter(#authenticationRepository), + returnValue: _FakeIAuthenticationRepository_9( + this, + Invocation.getter(#authenticationRepository), + ), + ) as _i11.IAuthenticationRepository); @override - _i10.Future<_i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>> call( - _i15.SignUpParams? params) => - (super.noSuchMethod(Invocation.method(#call, [params]), - returnValue: Future< - _i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>>.value( - _FakeEither_4<_i13.SignUpFailure, _i14.LoggedInUser>())) - as _i10.Future<_i6.Either<_i13.SignUpFailure, _i14.LoggedInUser>>); + _i12.Future<_i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>> call( + _i17.SignUpParams? params) => + (super.noSuchMethod( + Invocation.method( + #call, + [params], + ), + returnValue: _i12 + .Future<_i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>>.value( + _FakeEither_8<_i15.SignUpFailure, _i16.LoggedInUser>( + this, + Invocation.method( + #call, + [params], + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignUpFailure, _i16.LoggedInUser>>); } /// A class which mocks [SignInWithEmailAndPassword]. /// /// See the documentation for Mockito's code generation for more information. class MockSignInWithEmailAndPassword extends _i1.Mock - implements _i16.SignInWithEmailAndPassword { + implements _i18.SignInWithEmailAndPassword { MockSignInWithEmailAndPassword() { _i1.throwOnMissingStub(this); } @override - _i7.EmailValidator get emailValidator => - (super.noSuchMethod(Invocation.getter(#emailValidator), - returnValue: _FakeEmailValidator_5()) as _i7.EmailValidator); + _i8.EmailValidator get emailValidator => (super.noSuchMethod( + Invocation.getter(#emailValidator), + returnValue: _FakeEmailValidator_6( + this, + Invocation.getter(#emailValidator), + ), + ) as _i8.EmailValidator); + @override + _i11.IAuthenticationRepository get authenticationRepository => + (super.noSuchMethod( + Invocation.getter(#authenticationRepository), + returnValue: _FakeIAuthenticationRepository_9( + this, + Invocation.getter(#authenticationRepository), + ), + ) as _i11.IAuthenticationRepository); + @override + _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>> call( + _i18.SignInParams? params) => + (super.noSuchMethod( + Invocation.method( + #call, + [params], + ), + returnValue: _i12 + .Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>.value( + _FakeEither_8<_i15.SignInFailure, _i16.LoggedInUser>( + this, + Invocation.method( + #call, + [params], + ), + )), + ) as _i12.Future<_i10.Either<_i15.SignInFailure, _i16.LoggedInUser>>); +} + +/// A class which mocks [KeyValueDataSource]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockKeyValueDataSource extends _i1.Mock + implements _i19.KeyValueDataSource { + MockKeyValueDataSource() { + _i1.throwOnMissingStub(this); + } + + @override + String? getValue(String? key) => (super.noSuchMethod(Invocation.method( + #getValue, + [key], + )) as String?); + @override + _i12.Future setValue( + String? key, + String? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setValue, + [ + key, + value, + ], + ), + returnValue: _i12.Future.value(), + returnValueForMissingStub: _i12.Future.value(), + ) as _i12.Future); +} + +/// A class which mocks [FingerPrintAuthRepository]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockFingerPrintAuthRepository extends _i1.Mock + implements _i20.FingerPrintAuthRepository { + MockFingerPrintAuthRepository() { + _i1.throwOnMissingStub(this); + } + + @override + _i2.IKeyValueDataSource get keyValueDataSource => (super.noSuchMethod( + Invocation.getter(#keyValueDataSource), + returnValue: _FakeIKeyValueDataSource_0( + this, + Invocation.getter(#keyValueDataSource), + ), + ) as _i2.IKeyValueDataSource); + @override + _i3.AuthSessionBloc get authSessionBloc => (super.noSuchMethod( + Invocation.getter(#authSessionBloc), + returnValue: _FakeAuthSessionBloc_10( + this, + Invocation.getter(#authSessionBloc), + ), + ) as _i3.AuthSessionBloc); + @override + _i11.IAuthenticationRepository get authenticationRepository => + (super.noSuchMethod( + Invocation.getter(#authenticationRepository), + returnValue: _FakeIAuthenticationRepository_9( + this, + Invocation.getter(#authenticationRepository), + ), + ) as _i11.IAuthenticationRepository); + @override + set fingerPrintAuthStreamSubscription( + _i12.StreamSubscription<_i11.FingerPrintAuthState?>? + _fingerPrintAuthStreamSubscription) => + super.noSuchMethod( + Invocation.setter( + #fingerPrintAuthStreamSubscription, + _fingerPrintAuthStreamSubscription, + ), + returnValueForMissingStub: null, + ); + @override + bool get isFingerPrintAuthActivated => (super.noSuchMethod( + Invocation.getter(#isFingerPrintAuthActivated), + returnValue: false, + ) as bool); + @override + set isFingerPrintAuthActivated(bool? _isFingerPrintAuthActivated) => + super.noSuchMethod( + Invocation.setter( + #isFingerPrintAuthActivated, + _isFingerPrintAuthActivated, + ), + returnValueForMissingStub: null, + ); + @override + bool shouldActivateFingerPrint() => (super.noSuchMethod( + Invocation.method( + #shouldActivateFingerPrint, + [], + ), + returnValue: false, + ) as bool); @override - _i9.IAuthenticationRepository get authenticationRepository => - (super.noSuchMethod(Invocation.getter(#authenticationRepository), - returnValue: _FakeIAuthenticationRepository_7()) - as _i9.IAuthenticationRepository); + void startFingerPrintAuthIfNeeded() => super.noSuchMethod( + Invocation.method( + #startFingerPrintAuthIfNeeded, + [], + ), + returnValueForMissingStub: null, + ); @override - _i10.Future<_i6.Either<_i13.SignInFailure, _i14.LoggedInUser>> call( - _i16.SignInParams? params) => - (super.noSuchMethod(Invocation.method(#call, [params]), - returnValue: Future< - _i6.Either<_i13.SignInFailure, _i14.LoggedInUser>>.value( - _FakeEither_4<_i13.SignInFailure, _i14.LoggedInUser>())) - as _i10.Future<_i6.Either<_i13.SignInFailure, _i14.LoggedInUser>>); + void cancel() => super.noSuchMethod( + Invocation.method( + #cancel, + [], + ), + returnValueForMissingStub: null, + ); } From 2f57535959cb68c2cbd439a399c205ae2d696da7 Mon Sep 17 00:00:00 2001 From: droidbg Date: Mon, 2 Oct 2023 19:32:59 +0530 Subject: [PATCH 3/3] [Binni] Fix. auth session TCs (#46) --- .../bloc/auth_session/auth_session_test.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/features/auth/presentation/bloc/auth_session/auth_session_test.dart b/test/features/auth/presentation/bloc/auth_session/auth_session_test.dart index 374f257a..68b7d158 100644 --- a/test/features/auth/presentation/bloc/auth_session/auth_session_test.dart +++ b/test/features/auth/presentation/bloc/auth_session/auth_session_test.dart @@ -3,17 +3,20 @@ import 'package:dairy_app/features/auth/domain/entities/logged_in_user.dart'; import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; +import '../auth_form/auth_form_test.mocks.dart'; + void main() { late AuthSessionBloc authSessionBloc; const LoggedInUser user = LoggedInUser(email: "sank@email.com", id: "77"); setUp(() { - authSessionBloc = AuthSessionBloc(); + authSessionBloc = + AuthSessionBloc(keyValueDataSource: MockKeyValueDataSource()); }); group("Testing AuthSessionBloc", () { test("Initial state should be unauthenticated", () { - expect(authSessionBloc.state, equals(Unauthenticated())); + expect(authSessionBloc.state, equals(const Unauthenticated())); }); blocTest( @@ -34,9 +37,9 @@ void main() { }, expect: () => [ const Authenticated(user: user), - Unauthenticated(), + const Unauthenticated(), const Authenticated(user: user), - Unauthenticated(), + const Unauthenticated(), ], ); });