fix(authentication)!: use correct usecase and result
This commit is contained in:
parent
283bf80243
commit
cca7b29a6d
@ -27,34 +27,34 @@ class ExampleAuthenticationCubit extends AuthenticationCubit<int> {
|
||||
Result<Account, AppException> result) async {
|
||||
debugPrint('onReauthenticate');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOrResult<int?> onRefresh(Result<Account, AppException> result) {
|
||||
debugPrint('onRefresh');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOrResult<int?> onSignInFromCache(AuthenticationSession<int> session) {
|
||||
debugPrint('onSignInFromCache');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOrResult<void> onSignOut() {
|
||||
debugPrint('onSignOut');
|
||||
|
||||
return const Ok(null);
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOrResult<void> onDelete() {
|
||||
debugPrint('onDelete');
|
||||
|
||||
return const Ok(null);
|
||||
return Ok(null);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ExampleSignInCubit extends SignInCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) {
|
||||
debugPrint('onSignInWithEmailAndPassword: ${result.ok?.accessToken}');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -38,7 +38,7 @@ class ExampleSignInCubit extends SignInCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) {
|
||||
debugPrint('onSignInAnonymously');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -46,6 +46,6 @@ class ExampleSignInCubit extends SignInCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) {
|
||||
debugPrint('onSignInWithGoogle');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ class ExampleSignUpCubit extends SignUpCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) async {
|
||||
debugPrint('onSignUpWithEmailAndPassword');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class ExampleEditAccountCubit extends EditAccountCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) async {
|
||||
debugPrint('onEmailUpdated');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -36,6 +36,6 @@ class ExampleEditAccountCubit extends EditAccountCubit<int> {
|
||||
Result<Account, AppException> result, WyattForm form) async {
|
||||
debugPrint('onPasswordUpdated');
|
||||
|
||||
return const Ok(1);
|
||||
return Ok(1);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart';
|
||||
/// {@template authentication_cache_data_source}
|
||||
/// A data source that manages the cache strategy.
|
||||
/// {@endtemplate}
|
||||
abstract class AuthenticationCacheDataSource<Data> extends BaseLocalDataSource {
|
||||
abstract class AuthenticationCacheDataSource<Data> extends BaseDataSource {
|
||||
/// {@macro authentication_cache_data_source}
|
||||
const AuthenticationCacheDataSource();
|
||||
|
||||
|
@ -20,8 +20,7 @@ import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||
/// {@template authentication_session_data_source}
|
||||
/// A data source that manages the current session.
|
||||
/// {@endtemplate}
|
||||
abstract class AuthenticationSessionDataSource<Data>
|
||||
extends BaseLocalDataSource {
|
||||
abstract class AuthenticationSessionDataSource<Data> extends BaseDataSource {
|
||||
/// {@macro authentication_session_data_source}
|
||||
const AuthenticationSessionDataSource();
|
||||
|
||||
|
@ -22,8 +22,7 @@ import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart';
|
||||
/// It is responsible for all the external communication with the authentication
|
||||
/// providers.
|
||||
/// {@endtemplate}
|
||||
abstract class AuthenticationRemoteDataSource<Data>
|
||||
extends BaseRemoteDataSource {
|
||||
abstract class AuthenticationRemoteDataSource<Data> extends BaseDataSource {
|
||||
/// {@macro authentication_remote_data_source}
|
||||
const AuthenticationRemoteDataSource();
|
||||
|
||||
|
@ -43,12 +43,12 @@ class EditAccountCubit<Data> extends BaseEditAccountCubit<Data>
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<Data?> onPasswordUpdated(
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
}
|
||||
|
@ -48,19 +48,19 @@ class SignInCubit<Data> extends BaseSignInCubit<Data>
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<Data?> onSignInWithEmailAndPassword(
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<Data?> onSignInWithGoogle(
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
}
|
||||
|
@ -43,5 +43,5 @@ class SignUpCubit<Data> extends BaseSignUpCubit<Data>
|
||||
Result<Account, AppException> result,
|
||||
WyattForm form,
|
||||
) =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
}
|
||||
|
@ -30,26 +30,26 @@ class TestAuthenticationCubit extends AuthenticationCubit<int> {
|
||||
TestAuthenticationCubit({required super.authenticationRepository});
|
||||
|
||||
@override
|
||||
FutureOrResult<void> onDelete() async => const Ok(null);
|
||||
FutureOrResult<void> onDelete() async => Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<int?> onReauthenticate(
|
||||
Result<Account, AppException> result,
|
||||
) async =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<int?> onRefresh(Result<Account, AppException> result) async =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<int?> onSignInFromCache(
|
||||
AuthenticationSession<int> session,
|
||||
) async =>
|
||||
const Ok(null);
|
||||
Ok(null);
|
||||
|
||||
@override
|
||||
FutureOrResult<void> onSignOut() async => const Ok(null);
|
||||
FutureOrResult<void> onSignOut() async => Ok(null);
|
||||
}
|
||||
|
||||
void main() {
|
||||
@ -92,7 +92,7 @@ void main() {
|
||||
build: () => TestAuthenticationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const AuthenticationState.unknown(),
|
||||
seed: AuthenticationState.unknown,
|
||||
expect: () => [AuthenticationState<int>.authenticated(session)],
|
||||
);
|
||||
|
||||
@ -108,7 +108,7 @@ void main() {
|
||||
build: () => TestAuthenticationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const AuthenticationState.unknown(),
|
||||
seed: AuthenticationState.unknown,
|
||||
expect: () => [const AuthenticationState<int>.unauthenticated()],
|
||||
);
|
||||
});
|
||||
@ -119,7 +119,7 @@ void main() {
|
||||
setUp: () {
|
||||
when(
|
||||
() => authenticationRepository.signOut(),
|
||||
).thenAnswer((_) async => const Ok(null));
|
||||
).thenAnswer((_) async => Ok(null));
|
||||
},
|
||||
build: () => TestAuthenticationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
|
@ -84,7 +84,7 @@ void main() {
|
||||
'invokes sendEmailVerification,',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.sendEmailVerification())
|
||||
.thenAnswer((_) async => const Ok(null));
|
||||
.thenAnswer((_) async => Ok(null));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
@ -100,12 +100,12 @@ void main() {
|
||||
'emits success',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.sendEmailVerification())
|
||||
.thenAnswer((_) async => const Ok(null));
|
||||
.thenAnswer((_) async => Ok(null));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
seed: EmailVerificationState.new,
|
||||
act: (cubit) => cubit.sendEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
@ -121,12 +121,12 @@ void main() {
|
||||
'emits failure',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.sendEmailVerification())
|
||||
.thenAnswer((_) async => const Err(ServerException('erreur')));
|
||||
.thenAnswer((_) async => Err(const ServerException('erreur')));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
seed: EmailVerificationState.new,
|
||||
act: (cubit) => cubit.sendEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
@ -183,7 +183,7 @@ void main() {
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
seed: EmailVerificationState.new,
|
||||
act: (cubit) => cubit.checkEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
@ -206,7 +206,7 @@ void main() {
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
seed: EmailVerificationState.new,
|
||||
act: (cubit) => cubit.checkEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
@ -222,12 +222,12 @@ void main() {
|
||||
'emits failure on refresh error',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.refresh())
|
||||
.thenAnswer((_) async => const Err(ServerException('erreur')));
|
||||
.thenAnswer((_) async => Err(const ServerException('erreur')));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
seed: EmailVerificationState.new,
|
||||
act: (cubit) => cubit.checkEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
|
@ -57,7 +57,7 @@ void main() {
|
||||
() => authenticationRepository.sendPasswordResetEmail(
|
||||
email: any(named: 'email'),
|
||||
),
|
||||
).thenAnswer((_) async => const Ok(null));
|
||||
).thenAnswer((_) async => Ok(null));
|
||||
|
||||
when(
|
||||
() => authenticationRepository.formRepository,
|
||||
@ -157,7 +157,7 @@ void main() {
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
act: (cubit) => cubit.submit(),
|
||||
expect: () => const <PasswordResetState>[],
|
||||
expect: () => <PasswordResetState>[],
|
||||
);
|
||||
|
||||
blocTest<PasswordResetCubit<int>, PasswordResetState>(
|
||||
@ -272,7 +272,7 @@ void main() {
|
||||
() => authenticationRepository.sendPasswordResetEmail(
|
||||
email: any(named: 'email'),
|
||||
),
|
||||
).thenAnswer((_) async => const Err(ServerException()));
|
||||
).thenAnswer((_) async => Err(const ServerException()));
|
||||
when(
|
||||
() => formRepository.accessForm(AuthFormName.passwordResetForm),
|
||||
).thenAnswer(
|
||||
|
@ -435,7 +435,7 @@ void main() {
|
||||
email: any(named: 'email'),
|
||||
password: any(named: 'password'),
|
||||
),
|
||||
).thenAnswer((_) async => const Err(ServerException()));
|
||||
).thenAnswer((_) async => Err(const ServerException()));
|
||||
when(
|
||||
() => formRepository.accessForm(AuthFormName.signInForm),
|
||||
).thenAnswer(
|
||||
@ -615,7 +615,7 @@ void main() {
|
||||
setUp: () {
|
||||
when(
|
||||
() => authenticationRepository.signInAnonymously(),
|
||||
).thenAnswer((_) async => const Err(ServerException()));
|
||||
).thenAnswer((_) async => Err(const ServerException()));
|
||||
},
|
||||
build: () => SignInCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
|
@ -406,7 +406,7 @@ void main() {
|
||||
email: any(named: 'email'),
|
||||
password: any(named: 'password'),
|
||||
),
|
||||
).thenAnswer((_) async => const Err(ServerException()));
|
||||
).thenAnswer((_) async => Err(const ServerException()));
|
||||
when(
|
||||
() => formRepository.accessForm(AuthFormName.signUpForm),
|
||||
).thenAnswer(
|
||||
|
Loading…
x
Reference in New Issue
Block a user