use of com.kickstarter.models.Reward 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.Reward 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");
}
use of com.kickstarter.models.Reward in project android-oss by kickstarter.
the class ViewPledgeViewModelTest method testRewardMinimumAndDescriptionTextViewText.
@Test
public void testRewardMinimumAndDescriptionTextViewText() {
final Reward reward = RewardFactory.reward().toBuilder().minimum(100.0f).build();
final Backing backing = BackingFactory.backing().toBuilder().reward(reward).build();
final ViewPledgeViewModel vm = vm(backing);
final TestSubscriber<Pair<String, String>> rewardMinimumAndDescriptionTextViewTextTest = TestSubscriber.create();
vm.outputs.rewardMinimumAndDescriptionTextViewText().subscribe(rewardMinimumAndDescriptionTextViewTextTest);
vm.intent(intent(backing));
rewardMinimumAndDescriptionTextViewTextTest.assertValues(Pair.create("$100", backing.reward().description()));
}
Aggregations