use of rx.observers.TestSubscriber in project android-oss by kickstarter.
the class TwoFactorViewModelTest method testTwoFactorViewModel_TfaSuccessFacebook.
@Test
public void testTwoFactorViewModel_TfaSuccessFacebook() {
final Intent intent = new Intent();
intent.putExtra(IntentKey.EMAIL, "gina@kickstarter.com");
intent.putExtra(IntentKey.PASSWORD, "hello");
intent.putExtra(IntentKey.FACEBOOK_LOGIN, true);
intent.putExtra(IntentKey.FACEBOOK_TOKEN, "pajamas1234");
final TwoFactorViewModel vm = new TwoFactorViewModel(environment());
vm.intent(intent);
final TestSubscriber<Void> tfaSuccess = new TestSubscriber<>();
vm.outputs.tfaSuccess().subscribe(tfaSuccess);
final TestSubscriber<Boolean> formSubmitting = new TestSubscriber<>();
vm.outputs.formSubmitting().subscribe(formSubmitting);
vm.inputs.code("88888");
vm.inputs.loginClick();
formSubmitting.assertValues(true, false);
tfaSuccess.assertValueCount(1);
koalaTest.assertValues("Two-factor Authentication Confirm View", "Login");
}
use of rx.observers.TestSubscriber in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_WebViewUrl.
@Test
public void testUpdateViewModel_WebViewUrl() {
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment());
final Update update = UpdateFactory.update();
final TestSubscriber<String> webViewUrl = new TestSubscriber<>();
vm.outputs.webViewUrl().subscribe(webViewUrl);
// Start the intent with a project and update.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, ProjectFactory.project()).putExtra(IntentKey.UPDATE, update));
// Initial update index url emits.
webViewUrl.assertValues(update.urls().web().update());
}
use of rx.observers.TestSubscriber in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_UpdateSequence.
@Test
public void testUpdateViewModel_UpdateSequence() {
final Update initialUpdate = UpdateFactory.update().toBuilder().sequence(1).build();
final Update anotherUpdate = UpdateFactory.update().toBuilder().sequence(2).build();
final Request anotherUpdateRequest = new Request.Builder().url("https://kck.str/projects/param/param/posts/id").build();
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<Update> fetchUpdate(@NonNull final String projectParam, @NonNull final String updateParam) {
return Observable.just(anotherUpdate);
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment);
final TestSubscriber<String> updateSequence = new TestSubscriber<>();
vm.outputs.updateSequence().subscribe(updateSequence);
// Start the intent with a project and update.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, ProjectFactory.project()).putExtra(IntentKey.UPDATE, initialUpdate));
// Initial update's sequence number emits.
updateSequence.assertValues(NumberUtils.format(initialUpdate.sequence()));
vm.inputs.goToUpdateRequest(anotherUpdateRequest);
// New sequence should emit for new update page.
updateSequence.assertValues(NumberUtils.format(initialUpdate.sequence()), NumberUtils.format(anotherUpdate.sequence()));
}
use of rx.observers.TestSubscriber in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_StartCommentsActivity.
@Test
public void testUpdateViewModel_StartCommentsActivity() {
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment());
final Update update = UpdateFactory.update();
final Request commentsRequest = new Request.Builder().url("https://kck.str/projects/param/param/posts/id/comments").build();
final TestSubscriber<Update> startCommentsActivity = new TestSubscriber<>();
vm.outputs.startCommentsActivity().subscribe(startCommentsActivity);
// Start the intent with a project and update.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, ProjectFactory.project()).putExtra(IntentKey.UPDATE, update));
vm.inputs.goToCommentsRequest(commentsRequest);
startCommentsActivity.assertValues(update);
}
use of rx.observers.TestSubscriber in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_StartProjectActivity.
@Test
public void testUpdateViewModel_StartProjectActivity() {
final Update update = UpdateFactory.update().toBuilder().projectId(1234).build();
final Project project = ProjectFactory.project().toBuilder().id(update.projectId()).build();
final Request projectRequest = new Request.Builder().url("https://kck.str/projects/param/param").build();
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<Project> fetchProject(@NonNull final String param) {
return Observable.just(project);
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment);
final TestSubscriber<Project> startProjectActivity = new TestSubscriber<>();
vm.outputs.startProjectActivity().map(pr -> pr.first).subscribe(startProjectActivity);
// Start the intent with a project and update.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project).putExtra(IntentKey.UPDATE, update));
vm.inputs.goToProjectRequest(projectRequest);
startProjectActivity.assertValues(project);
}
Aggregations