use of com.kickstarter.models.Reward in project android-oss by kickstarter.
the class ViewPledgeViewModelTest method testShipping_withShippingLocation.
@Test
public void testShipping_withShippingLocation() {
final Location location = LocationFactory.sydney();
final Reward reward = RewardFactory.rewardWithShipping();
final Backing backing = BackingFactory.backing().toBuilder().location(location).reward(reward).rewardId(reward.id()).shippingAmount(5.0f).build();
final ViewPledgeViewModel vm = vm(backing);
final TestSubscriber<String> shippingLocationTextViewTextTest = TestSubscriber.create();
vm.outputs.shippingLocationTextViewText().subscribe(shippingLocationTextViewTextTest);
final TestSubscriber<String> shippingAmountTextViewTextTest = TestSubscriber.create();
vm.outputs.shippingAmountTextViewText().subscribe(shippingAmountTextViewTextTest);
final TestSubscriber<Boolean> shippingSectionIsHiddenTest = TestSubscriber.create();
vm.outputs.shippingSectionIsHidden().subscribe(shippingSectionIsHiddenTest);
vm.intent(intent(backing));
shippingLocationTextViewTextTest.assertValues("Sydney, AU");
shippingAmountTextViewTextTest.assertValues("$5");
shippingSectionIsHiddenTest.assertValues(false);
}
use of com.kickstarter.models.Reward in project android-oss by kickstarter.
the class RewardViewModelTest method testRewardsItems.
@Test
public void testRewardsItems() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Boolean> rewardsItemsAreHiddenTest = TestSubscriber.create();
vm.outputs.rewardsItemsAreHidden().subscribe(rewardsItemsAreHiddenTest);
final TestSubscriber<List<RewardsItem>> rewardsItemsTest = TestSubscriber.create();
vm.outputs.rewardsItems().subscribe(rewardsItemsTest);
// Items section should be hidden when there are no items.
vm.inputs.projectAndReward(project, RewardFactory.reward());
rewardsItemsAreHiddenTest.assertValue(true);
rewardsItemsTest.assertValue(emptyList());
final Reward itemizedReward = RewardFactory.itemized();
vm.inputs.projectAndReward(project, itemizedReward);
rewardsItemsAreHiddenTest.assertValues(true, false);
rewardsItemsTest.assertValues(emptyList(), itemizedReward.rewardsItems());
}
use of com.kickstarter.models.Reward in project android-oss by kickstarter.
the class RewardViewModelTest method testDescriptionTextViewText.
@Test
public void testDescriptionTextViewText() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final Reward reward = RewardFactory.reward();
final TestSubscriber<String> descriptionTextViewTextTest = TestSubscriber.create();
vm.outputs.descriptionTextViewText().subscribe(descriptionTextViewTextTest);
vm.inputs.projectAndReward(project, reward);
descriptionTextViewTextTest.assertValue(reward.description());
}
use of com.kickstarter.models.Reward 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.Reward 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);
}
Aggregations