You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing an event, inside that event other event was triggered; I used many way's to test it, but Could you guys give me guideline to use it correctly.
Thanks in advance;
The first event:
...
if (result.right.success) {
emit(
state.copyWith(
phone: event.phoneNumber,
isNewUser: false,
loginStatus: FormzSubmissionStatus.success,
email: result.right.email,
loginResponseEntity: result.right,
isInternationalPhone: state.selectedCountry.countryCode.toLowerCase() != "uz"),
);
add(GetVerificationCode()); // <= this is triggered;
}
...
test for the event :
blocTest<AuthBloc, AuthState>(
"should check phone number and continue as a registered user with local phone number",
build: () => authBloc,
setUp: () {
when(() => checkPhoneUseCaseMock.call(tPhoneNumber)).thenAnswer((_) async => Right(tCheckResponseEntity));
},
act: (bloc) {
bloc.add(CheckPhone(phoneNumber: tPhoneNumber));
},
expect: () => [
isA().having((state) => state.loginStatus, "progress state", FormzSubmissionStatus.inProgress),
isA()
.having((state) => state.loginStatus, "loginStatus", FormzSubmissionStatus.success)
.having((state) => state.isNewUser, "isNewUser", false)
.having((state) => state.phone, "phone", tPhoneNumber)
.having((state) => state.loginResponseEntity, "loginResponseEntity", tCheckResponseEntity)
.having((state) => state.isInternationalPhone, "isInternationalPhone", false)
.having((state) => state.email, "email", ""),
isA()
.having((state) => state.loginStatus, "loginStatus", FormzSubmissionStatus.initial)
.having((state) => state.message, "error message", ""),
],
verify: (bloc) {
// check phone number is called once
verify(() => checkPhoneUseCaseMock.call(tPhoneNumber)).called(1);
final mockBloc = bloc as AuthBlocMock;
expect(mockBloc.capturedEvents, contains(isA<GetVerificationCode>()));
},
);
The text was updated successfully, but these errors were encountered:
Thanks in advance for maintaining the package;
I was testing an event, inside that event other event was triggered; I used many way's to test it, but Could you guys give me guideline to use it correctly.
Thanks in advance;
The first event:
...
if (result.right.success) {
emit(
state.copyWith(
phone: event.phoneNumber,
isNewUser: false,
loginStatus: FormzSubmissionStatus.success,
email: result.right.email,
loginResponseEntity: result.right,
isInternationalPhone: state.selectedCountry.countryCode.toLowerCase() != "uz"),
);
add(GetVerificationCode()); // <= this is triggered;
}
...
test for the event :
blocTest<AuthBloc, AuthState>(
"should check phone number and continue as a registered user with local phone number",
build: () => authBloc,
setUp: () {
when(() => checkPhoneUseCaseMock.call(tPhoneNumber)).thenAnswer((_) async => Right(tCheckResponseEntity));
},
act: (bloc) {
bloc.add(CheckPhone(phoneNumber: tPhoneNumber));
},
expect: () => [
isA().having((state) => state.loginStatus, "progress state", FormzSubmissionStatus.inProgress),
isA()
.having((state) => state.loginStatus, "loginStatus", FormzSubmissionStatus.success)
.having((state) => state.isNewUser, "isNewUser", false)
.having((state) => state.phone, "phone", tPhoneNumber)
.having((state) => state.loginResponseEntity, "loginResponseEntity", tCheckResponseEntity)
.having((state) => state.isInternationalPhone, "isInternationalPhone", false)
.having((state) => state.email, "email", ""),
isA()
.having((state) => state.loginStatus, "loginStatus", FormzSubmissionStatus.initial)
.having((state) => state.message, "error message", ""),
],
verify: (bloc) {
// check phone number is called once
verify(() => checkPhoneUseCaseMock.call(tPhoneNumber)).called(1);
The text was updated successfully, but these errors were encountered: