use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testGoToCheckoutWhenProjectIsSuccessfulAndHasBeenBacked.
@Test
public void testGoToCheckoutWhenProjectIsSuccessfulAndHasBeenBacked() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.backedProject().toBuilder().state(Project.STATE_SUCCESSFUL).build();
final Reward reward = project.backing().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 RewardViewModelTest method testWhiteOverlayIsHidden.
@Test
public void testWhiteOverlayIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Boolean> whiteOverlayIsHiddenTest = TestSubscriber.create();
vm.outputs.whiteOverlayIsHidden().subscribe(whiteOverlayIsHiddenTest);
vm.inputs.projectAndReward(project, RewardFactory.reward());
whiteOverlayIsHiddenTest.assertValue(true);
final Project backedProjectWithRewardLimitReached = ProjectFactory.backedProjectWithRewardLimitReached();
vm.inputs.projectAndReward(backedProjectWithRewardLimitReached, backedProjectWithRewardLimitReached.backing().reward());
whiteOverlayIsHiddenTest.assertValues(true);
vm.inputs.projectAndReward(project, RewardFactory.limitReached());
whiteOverlayIsHiddenTest.assertValues(true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testUsdConversionForNonUSProject.
@Test
public void testUsdConversionForNonUSProject() {
// Set user's country to US.
final Config config = ConfigFactory.configForUSUser();
final Environment environment = environment();
final CurrentConfigType currentConfig = environment.currentConfig();
environment.currentConfig().config(config);
final RewardViewModel vm = new RewardViewModel(environment);
// Set project's country to CA.
final Project project = ProjectFactory.caProject();
final Reward reward = RewardFactory.reward();
final TestSubscriber<String> usdConversionTextViewText = TestSubscriber.create();
vm.outputs.usdConversionTextViewText().subscribe(usdConversionTextViewText);
final TestSubscriber<Boolean> usdConversionSectionIsHidden = TestSubscriber.create();
vm.outputs.usdConversionTextViewIsHidden().subscribe(usdConversionSectionIsHidden);
// USD conversion should be shown.
vm.inputs.projectAndReward(project, reward);
usdConversionTextViewText.assertValueCount(1);
usdConversionSectionIsHidden.assertValue(false);
// Set user's country to CA (any country except the US is fine).
currentConfig.config(ConfigFactory.configForCAUser());
// USD conversion should now be hidden.
usdConversionTextViewText.assertValueCount(1);
usdConversionSectionIsHidden.assertValues(false, true);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testAllGoneTextViewIsHidden.
@Test
public void testAllGoneTextViewIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.backedProjectWithRewardLimitReached();
final TestSubscriber<Boolean> allGoneTextViewIsHidden = TestSubscriber.create();
vm.outputs.allGoneTextViewIsHidden().subscribe(allGoneTextViewIsHidden);
// When an unlimited reward is not backed, hide the 'all gone' header.
vm.inputs.projectAndReward(project, RewardFactory.reward());
allGoneTextViewIsHidden.assertValues(true);
// When an unlimited reward is backed, hide the 'all gone' header (distinct until changed).
final Reward backedReward = project.backing().reward();
vm.inputs.projectAndReward(project, backedReward);
allGoneTextViewIsHidden.assertValues(true);
// When a backed reward's limit has been reached, hide the 'all gone' header – the selected banner will be shown instead.
final Reward backedRewardWithLimitReached = backedReward.toBuilder().limit(1).remaining(0).build();
vm.inputs.projectAndReward(project, backedRewardWithLimitReached);
allGoneTextViewIsHidden.assertValues(true);
// When a reward's limit has been reached and it has not been backed, show the 'all gone' header.
vm.inputs.projectAndReward(project, RewardFactory.limitReached());
allGoneTextViewIsHidden.assertValues(true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testUsdConversionTextRoundsUp.
@Test
public void testUsdConversionTextRoundsUp() {
// Set user's country to US.
final Config config = ConfigFactory.configForUSUser();
final Environment environment = environment();
environment.currentConfig().config(config);
final RewardViewModel vm = new RewardViewModel(environment);
// Set project's country to CA and reward minimum to $0.30.
final Project project = ProjectFactory.caProject();
final Reward reward = RewardFactory.reward().toBuilder().minimum(0.3f).build();
final TestSubscriber<String> usdConversionTextViewText = TestSubscriber.create();
vm.outputs.usdConversionTextViewText().subscribe(usdConversionTextViewText);
// USD conversion should be rounded up.
vm.inputs.projectAndReward(project, reward);
usdConversionTextViewText.assertValue("$1");
}
Aggregations