use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testEstimatedDeliveryDateTextViewText.
@Test
public void testEstimatedDeliveryDateTextViewText() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final Reward reward = RewardFactory.reward().toBuilder().estimatedDeliveryOn(null).build();
final TestSubscriber<DateTime> estimatedDeliveryDateTextViewTextTest = TestSubscriber.create();
vm.outputs.estimatedDeliveryDateTextViewText().subscribe(estimatedDeliveryDateTextViewTextTest);
vm.inputs.projectAndReward(project, reward);
// If reward has no estimated delivery, no value should be emitted.
estimatedDeliveryDateTextViewTextTest.assertNoValues();
// Reward with estimated delivery should emit.
final DateTime estimatedDelivery = DateTime.now();
vm.inputs.projectAndReward(project, reward.toBuilder().estimatedDeliveryOn(estimatedDelivery).build());
estimatedDeliveryDateTextViewTextTest.assertValue(estimatedDelivery);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testGoToCheckoutWhenProjectIsSuccessful.
@Test
public void testGoToCheckoutWhenProjectIsSuccessful() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.successfulProject();
final Reward reward = RewardFactory.reward();
final TestSubscriber<Pair<Project, Reward>> goToCheckoutTest = TestSubscriber.create();
vm.outputs.goToCheckout().subscribe(goToCheckoutTest);
vm.inputs.projectAndReward(project, reward);
goToCheckoutTest.assertNoValues();
vm.inputs.rewardClicked();
goToCheckoutTest.assertNoValues();
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySeen.
@Test
public void testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySeen() {
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(true);
final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
final ThanksViewModel vm = new ThanksViewModel(environment);
final TestSubscriber<Void> showGamesNewsletterDialogTest = new TestSubscriber<>();
vm.outputs.showGamesNewsletterDialog().subscribe(showGamesNewsletterDialogTest);
final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
showGamesNewsletterDialogTest.assertValueCount(0);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_share.
@Test
public void testThanksViewModel_share() {
final ThanksViewModel vm = new ThanksViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Project> startShareTest = new TestSubscriber<>();
vm.outputs.startShare().subscribe(startShareTest);
final TestSubscriber<Project> startShareOnFacebookTest = new TestSubscriber<>();
vm.outputs.startShareOnFacebook().subscribe(startShareOnFacebookTest);
final TestSubscriber<Project> startShareOnTwitterTest = new TestSubscriber<>();
vm.outputs.startShareOnTwitter().subscribe(startShareOnTwitterTest);
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
vm.inputs.shareClick();
startShareTest.assertValues(project);
koalaTest.assertValues("Checkout Show Share Sheet");
vm.inputs.shareOnFacebookClick();
startShareOnFacebookTest.assertValues(project);
koalaTest.assertValues("Checkout Show Share Sheet", "Checkout Show Share");
vm.inputs.shareOnTwitterClick();
startShareOnTwitterTest.assertValues(project);
koalaTest.assertValues("Checkout Show Share Sheet", "Checkout Show Share", "Checkout Show Share");
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectUpdatesViewModelTest method testProjectUpdatesViewModel_StartUpdateActivity.
@Test
public void testProjectUpdatesViewModel_StartUpdateActivity() {
final ProjectUpdatesViewModel.ViewModel vm = new ProjectUpdatesViewModel.ViewModel(environment());
final Project project = ProjectFactory.project();
final Request updateRequest = new Request.Builder().url("https://kck.str/projects/param/param/posts/id").build();
final TestSubscriber<Pair<Project, Update>> startUpdateActivity = new TestSubscriber<>();
vm.outputs.startUpdateActivity().subscribe(startUpdateActivity);
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
vm.inputs.goToUpdateRequest(updateRequest);
startUpdateActivity.assertValueCount(1);
koalaTest.assertValues(KoalaEvent.VIEWED_UPDATES, KoalaEvent.VIEWED_UPDATE);
}
Aggregations