Search in sources :

Example 6 with Reward

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);
}
Also used : Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) Location(com.kickstarter.models.Location) Test(org.junit.Test)

Example 7 with Reward

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());
}
Also used : Project(com.kickstarter.models.Project) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Reward(com.kickstarter.models.Reward) Test(org.junit.Test)

Example 8 with Reward

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());
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Test(org.junit.Test)

Example 9 with Reward

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");
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Test(org.junit.Test)

Example 10 with Reward

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);
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Test(org.junit.Test)

Aggregations

Reward (com.kickstarter.models.Reward)28 Project (com.kickstarter.models.Project)19 Test (org.junit.Test)19 Backing (com.kickstarter.models.Backing)7 Pair (android.util.Pair)5 NonNull (android.support.annotation.NonNull)3 Config (com.kickstarter.libs.Config)3 Environment (com.kickstarter.libs.Environment)3 Collections.emptyList (java.util.Collections.emptyList)3 List (java.util.List)3 CurrentConfigType (com.kickstarter.libs.CurrentConfigType)2 Location (com.kickstarter.models.Location)1 DateTime (org.joda.time.DateTime)1