use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testMinimumTextViewText.
@Test
public void testMinimumTextViewText() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final Reward reward = RewardFactory.reward().toBuilder().minimum(10).build();
final TestSubscriber<String> minimumTextViewTextTest = TestSubscriber.create();
vm.outputs.minimumTextViewText().subscribe(minimumTextViewTextTest);
vm.inputs.projectAndReward(project, reward);
minimumTextViewTextTest.assertValue("$10");
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testLimitAndBackersSeparatorIsHidden.
@Test
public void testLimitAndBackersSeparatorIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Boolean> limitAndBackersSeparatorIsHiddenTest = TestSubscriber.create();
vm.outputs.limitAndBackersSeparatorIsHidden().subscribe(limitAndBackersSeparatorIsHiddenTest);
// When reward has no limit or backers, separator should be hidden.
vm.inputs.projectAndReward(project, RewardFactory.noBackers());
limitAndBackersSeparatorIsHiddenTest.assertValues(true);
// When reward has no limit and backers, separator should be hidden.
vm.inputs.projectAndReward(project, RewardFactory.reward());
limitAndBackersSeparatorIsHiddenTest.assertValues(true);
// When reward has limit and no backers, separator should be hidden.
vm.inputs.projectAndReward(project, RewardFactory.limited().toBuilder().backersCount(0).build());
limitAndBackersSeparatorIsHiddenTest.assertValues(true);
// When reward has limit and backers, separator should be visible.
vm.inputs.projectAndReward(project, RewardFactory.limited().toBuilder().build());
limitAndBackersSeparatorIsHiddenTest.assertValues(true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testShippingSummary.
@Test
public void testShippingSummary() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<String> shippingSummaryTextViewTextTest = TestSubscriber.create();
vm.outputs.shippingSummaryTextViewText().subscribe(shippingSummaryTextViewTextTest);
final TestSubscriber<Boolean> shippingSummarySectionIsHiddenTest = TestSubscriber.create();
vm.outputs.shippingSummarySectionIsHidden().subscribe(shippingSummarySectionIsHiddenTest);
// Reward with no shipping should hide shipping summary section and not emit a shipping summary string.
vm.inputs.projectAndReward(project, RewardFactory.reward());
shippingSummaryTextViewTextTest.assertNoValues();
shippingSummarySectionIsHiddenTest.assertValue(true);
// Reward with shipping should show shipping summary section and emit a shipping summary string.
final Reward rewardWithShipping = RewardFactory.rewardWithShipping();
vm.inputs.projectAndReward(project, rewardWithShipping);
shippingSummaryTextViewTextTest.assertValue(rewardWithShipping.shippingSummary());
shippingSummarySectionIsHiddenTest.assertValues(true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testLimitHeaderIsHidden.
@Test
public void testLimitHeaderIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final TestSubscriber<Boolean> limitHeaderIsHiddenTest = TestSubscriber.create();
vm.outputs.limitHeaderIsHidden().subscribe(limitHeaderIsHiddenTest);
// If the reward is limited and has not been backed, show the limit header.
final Project backedProjectWithLimitedReward = ProjectFactory.backedProjectWithRewardLimited();
vm.inputs.projectAndReward(backedProjectWithLimitedReward, RewardFactory.limited());
limitHeaderIsHiddenTest.assertValues(false);
// If the reward is limited and has been backed, don't show the limit header.
vm.inputs.projectAndReward(backedProjectWithLimitedReward, backedProjectWithLimitedReward.backing().reward());
limitHeaderIsHiddenTest.assertValues(false, true);
// If the reward is not limited, don't show the limit header.
vm.inputs.projectAndReward(ProjectFactory.project(), RewardFactory.reward());
limitHeaderIsHiddenTest.assertValues(false, true);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testBackersTextView.
@Test
public void testBackersTextView() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final Reward rewardWithBackers = RewardFactory.reward().toBuilder().backersCount(100).build();
final TestSubscriber<Integer> backersTextViewTextTest = TestSubscriber.create();
vm.outputs.backersTextViewText().subscribe(backersTextViewTextTest);
// Show reward backer count.
vm.inputs.projectAndReward(project, rewardWithBackers);
backersTextViewTextTest.assertValue(100);
}
Aggregations