test(authentication): update tests
This commit is contained in:
+15
-31
@@ -39,15 +39,21 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
authenticationRepository = MockAuthenticationRepository();
|
||||
when(
|
||||
() => authenticationRepository.getAccount(),
|
||||
).thenAnswer((_) async => Ok(account));
|
||||
account = MockAccount();
|
||||
|
||||
when(() => authenticationRepository.sessionStream()).thenAnswer(
|
||||
(_) => Stream.fromIterable([
|
||||
SessionWrapper<int>(
|
||||
event: SignedInFromCacheEvent(account: account),
|
||||
session: Session<int>(account: account, data: 10),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
when(
|
||||
() => authenticationRepository.refresh(),
|
||||
).thenAnswer((_) async => const Ok(null));
|
||||
).thenAnswer((_) async => Ok(account));
|
||||
|
||||
account = MockAccount();
|
||||
when(
|
||||
() => account.emailVerified,
|
||||
).thenAnswer((_) => true);
|
||||
@@ -129,7 +135,7 @@ void main() {
|
||||
setUp: () {
|
||||
when(
|
||||
() => authenticationRepository.refresh(),
|
||||
).thenAnswer((_) async => const Ok(null));
|
||||
).thenAnswer((_) async => Ok(account));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
@@ -145,7 +151,7 @@ void main() {
|
||||
setUp: () {
|
||||
when(
|
||||
() => authenticationRepository.refresh(),
|
||||
).thenAnswer((_) async => const Ok(null));
|
||||
).thenAnswer((_) async => Ok(account));
|
||||
when(() => account.emailVerified).thenAnswer((_) => false);
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
@@ -161,7 +167,7 @@ void main() {
|
||||
'emits success with true if verified',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.refresh())
|
||||
.thenAnswer((_) async => const Ok(null));
|
||||
.thenAnswer((_) async => Ok(account));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
@@ -183,7 +189,7 @@ void main() {
|
||||
'emits success with false if not verified',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.refresh())
|
||||
.thenAnswer((_) async => const Ok(null));
|
||||
.thenAnswer((_) async => Ok(account));
|
||||
when(() => account.emailVerified).thenAnswer((_) => false);
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
@@ -222,28 +228,6 @@ void main() {
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
blocTest<EmailVerificationCubit<int>, EmailVerificationState>(
|
||||
'emits failure on get account error',
|
||||
setUp: () {
|
||||
when(() => authenticationRepository.getAccount())
|
||||
.thenAnswer((_) async => Err(ServerException('erreur')));
|
||||
},
|
||||
build: () => EmailVerificationCubit(
|
||||
authenticationRepository: authenticationRepository,
|
||||
),
|
||||
seed: () => const EmailVerificationState(),
|
||||
act: (cubit) => cubit.checkEmailVerification(),
|
||||
expect: () => [
|
||||
const EmailVerificationState(
|
||||
status: FormStatus.submissionInProgress,
|
||||
),
|
||||
const EmailVerificationState(
|
||||
errorMessage: 'erreur',
|
||||
status: FormStatus.submissionFailure,
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user