use of com.kickstarter.libs.Environment 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.libs.Environment in project android-oss by kickstarter.
the class CheckoutViewModelTest method test_AndroidPayIsAvailable_WhenNotCapable.
@Test
public void test_AndroidPayIsAvailable_WhenNotCapable() {
final Environment env = environment().toBuilder().androidPayCapability(new AndroidPayCapability(false)).build();
final CheckoutViewModel vm = new CheckoutViewModel(env);
vm.outputs.isAndroidPayAvailable().subscribe(Assert::assertFalse);
}
use of com.kickstarter.libs.Environment in project android-oss by kickstarter.
the class CheckoutViewModelTest method test_AndroidPayIsAvailable_WhenCapable.
@Test
public void test_AndroidPayIsAvailable_WhenCapable() {
final Environment env = environment().toBuilder().androidPayCapability(new AndroidPayCapability(true)).build();
final CheckoutViewModel vm = new CheckoutViewModel(env);
vm.outputs.isAndroidPayAvailable().subscribe(Assert::assertTrue);
}
use of com.kickstarter.libs.Environment 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.libs.Environment in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testProjectsRefreshAfterLogin.
@Test
public void testProjectsRefreshAfterLogin() {
final CurrentUserType currentUser = new MockCurrentUser();
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
final DiscoveryFragmentViewModel vm = new DiscoveryFragmentViewModel(environment);
final TestSubscriber<List<Project>> projects = new TestSubscriber<>();
vm.outputs.projects().filter(ListUtils::nonEmpty).subscribe(projects);
// Initial load.
vm.inputs.rootCategories(CategoryFactory.rootCategories());
vm.inputs.paramsFromActivity(DiscoveryParams.builder().sort(DiscoveryParams.Sort.HOME).build());
// Projects should emit.
projects.assertValueCount(1);
// Log in.
currentUser.refresh(UserFactory.user());
// Projects should emit again.
projects.assertValueCount(2);
}
Aggregations