use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class VideoViewModelTest method testVideoViewModel_EmitsVideoUrl.
@Test
public void testVideoViewModel_EmitsVideoUrl() {
final VideoViewModel.ViewModel vm = new VideoViewModel.ViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<String> preparePlayerWithUrl = new TestSubscriber<>();
vm.outputs.preparePlayerWithUrl().subscribe(preparePlayerWithUrl);
// Configure the view model with a project intent.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
preparePlayerWithUrl.assertValues(project.video().high());
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testBackersTextViewIsHidden.
@Test
public void testBackersTextViewIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Boolean> backersTextViewIsHiddenTest = TestSubscriber.create();
vm.outputs.backersTextViewIsHidden().subscribe(backersTextViewIsHiddenTest);
vm.inputs.projectAndReward(project, RewardFactory.noBackers());
backersTextViewIsHiddenTest.assertValues(true);
vm.inputs.projectAndReward(project, RewardFactory.noReward());
backersTextViewIsHiddenTest.assertValues(true);
vm.inputs.projectAndReward(project, RewardFactory.backers());
backersTextViewIsHiddenTest.assertValues(true, false);
}
use of com.kickstarter.models.Project 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.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testGoToViewPledge.
@Test
public void testGoToViewPledge() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project liveProject = ProjectFactory.backedProject();
final Project successfulProject = ProjectFactory.backedProject().toBuilder().state(Project.STATE_SUCCESSFUL).build();
final TestSubscriber<Project> goToViewPledgeTest = TestSubscriber.create();
vm.outputs.goToViewPledge().subscribe(goToViewPledgeTest);
vm.inputs.projectAndReward(liveProject, liveProject.backing().reward());
goToViewPledgeTest.assertNoValues();
// When the project is still live, don't go to 'view pledge'. Should go to checkout instead.
vm.inputs.rewardClicked();
goToViewPledgeTest.assertNoValues();
// When project is successful but not backed, don't go to view pledge.
vm.inputs.projectAndReward(successfulProject, RewardFactory.reward());
vm.inputs.rewardClicked();
goToViewPledgeTest.assertNoValues();
// When project is successful and backed, go to view pledge.
vm.inputs.projectAndReward(successfulProject, successfulProject.backing().reward());
goToViewPledgeTest.assertNoValues();
vm.inputs.rewardClicked();
goToViewPledgeTest.assertValues(successfulProject);
}
use of com.kickstarter.models.Project 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());
}
Aggregations