use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class ResetPasswordViewModelTest method testResetPasswordViewModel_resetFailure.
@Test
public void testResetPasswordViewModel_resetFailure() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<User> resetPassword(@NonNull final String email) {
return Observable.error(ApiExceptionFactory.badRequestException());
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final ResetPasswordViewModel vm = new ResetPasswordViewModel(environment);
final TestSubscriber<String> errorTest = new TestSubscriber<>();
koalaTest.assertValues("Forgot Password View");
vm.errors.resetError().subscribe(errorTest);
vm.inputs.email("hello@kickstarter.com");
vm.inputs.resetPasswordClick();
errorTest.assertValue("bad request");
koalaTest.assertValues("Forgot Password View", "Forgot Password Errored");
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class ProjectIntentMapperTest method testProject_emitsFromKsrProjectUri.
@Test
public void testProject_emitsFromKsrProjectUri() {
final Uri uri = Uri.parse("ksr://www.kickstarter.com/projects/1186238668/skull-graphic-tee");
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
final TestSubscriber<Project> resultTest = TestSubscriber.create();
ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
resultTest.assertValueCount(1);
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class ProjectIntentMapperTest method testProject_emitsFromProjectParamExtra.
@Test
public void testProject_emitsFromProjectParamExtra() {
final Intent intent = new Intent().putExtra(IntentKey.PROJECT_PARAM, "skull-graphic-tee");
final TestSubscriber<Project> resultTest = TestSubscriber.create();
ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
resultTest.assertValueCount(1);
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class CommentsViewModelTest method testCommentsViewModel_EmptyState.
@Test
public void testCommentsViewModel_EmptyState() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<CommentsEnvelope> fetchComments(@NonNull final Update update) {
return Observable.empty();
}
};
final Environment env = environment().toBuilder().apiClient(apiClient).build();
final CommentsViewModel vm = new CommentsViewModel(env);
final TestSubscriber<CommentsData> commentsData = new TestSubscriber<>();
vm.outputs.commentsData().subscribe(commentsData);
// Start the view model with an update.
vm.intent(new Intent().putExtra(IntentKey.UPDATE, UpdateFactory.update()));
// Only Viewed Comments event should fire.
koalaTest.assertValues(KoalaEvent.VIEWED_COMMENTS);
commentsData.assertNoValues();
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class LoginViewModelTest method testLoginApiValidationError.
@Test
public void testLoginApiValidationError() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> login(@NonNull final String email, @NonNull final String password) {
return Observable.error(ApiExceptionFactory.invalidLoginException());
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final LoginViewModel vm = new LoginViewModel(environment);
final TestSubscriber<String> invalidLoginError = new TestSubscriber<>();
vm.errors.invalidLoginError().subscribe(invalidLoginError);
final TestSubscriber<Void> loginSuccess = new TestSubscriber<>();
vm.outputs.loginSuccess().subscribe(loginSuccess);
vm.inputs.email("typo@kickstartr.com");
vm.inputs.password("danisawesome");
vm.inputs.loginClick();
loginSuccess.assertNoValues();
invalidLoginError.assertValueCount(1);
}
Aggregations