use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testUsdConversionNotShownForUSProject.
@Test
public void testUsdConversionNotShownForUSProject() {
// Set user's country to US.
final Config config = ConfigFactory.configForUSUser();
final Environment environment = environment();
final CurrentConfigType currentConfig = environment.currentConfig();
environment.currentConfig().config(config);
final RewardViewModel vm = new RewardViewModel(environment);
// Set project's country to US.
final Project project = ProjectFactory.project().toBuilder().country("US").build();
final Reward reward = RewardFactory.reward();
final TestSubscriber<String> usdConversionTextViewText = TestSubscriber.create();
vm.outputs.usdConversionTextViewText().subscribe(usdConversionTextViewText);
final TestSubscriber<Boolean> usdConversionSectionIsHidden = TestSubscriber.create();
vm.outputs.usdConversionTextViewIsHidden().subscribe(usdConversionSectionIsHidden);
// USD conversion should not be shown.
vm.inputs.projectAndReward(project, reward);
usdConversionTextViewText.assertNoValues();
usdConversionSectionIsHidden.assertValue(true);
// Set user's country to CA.
currentConfig.config(ConfigFactory.configForCAUser());
// USD conversion should still not be shown (distinct until changed).
usdConversionTextViewText.assertNoValues();
usdConversionSectionIsHidden.assertValues(true);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testEstimatedDeliveryDateSectionIsHidden.
@Test
public void testEstimatedDeliveryDateSectionIsHidden() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Boolean> estimatedDeliveryDateSectionIsHiddenTest = TestSubscriber.create();
vm.outputs.estimatedDeliveryDateSectionIsHidden().subscribe(estimatedDeliveryDateSectionIsHiddenTest);
// Reward with no estimated delivery should not show estimated delivery label.
vm.inputs.projectAndReward(project, RewardFactory.reward().toBuilder().estimatedDeliveryOn(null).build());
estimatedDeliveryDateSectionIsHiddenTest.assertValue(true);
// Reward with estimated delivery should show estimated delivery label.
vm.inputs.projectAndReward(project, RewardFactory.reward().toBuilder().estimatedDeliveryOn(DateTime.now()).build());
estimatedDeliveryDateSectionIsHiddenTest.assertValues(true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testIsClickable.
@Test
public void testIsClickable() {
final RewardViewModel vm = new RewardViewModel(environment());
final TestSubscriber<Boolean> isClickableTest = TestSubscriber.create();
vm.outputs.isClickable().subscribe(isClickableTest);
// A reward from a live project should be clickable.
vm.inputs.projectAndReward(ProjectFactory.project(), RewardFactory.reward());
isClickableTest.assertValue(true);
// A reward from a successful project should not be clickable.
vm.inputs.projectAndReward(ProjectFactory.successfulProject(), RewardFactory.reward());
isClickableTest.assertValues(true, false);
//
// A backed reward from a live project should be clickable.
final Project backedLiveProject = ProjectFactory.backedProject();
vm.inputs.projectAndReward(backedLiveProject, backedLiveProject.backing().reward());
isClickableTest.assertValues(true, false, true);
// A backed reward from a finished project should be clickable (distinct until changed).
final Project backedSuccessfulProject = ProjectFactory.backedProject().toBuilder().state(Project.STATE_SUCCESSFUL).build();
vm.inputs.projectAndReward(backedSuccessfulProject, backedSuccessfulProject.backing().reward());
isClickableTest.assertValues(true, false, true);
// A reward with its limit reached should not be clickable.
vm.inputs.projectAndReward(ProjectFactory.project(), RewardFactory.limitReached());
isClickableTest.assertValues(true, false, true, false);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testLimitAndRemaining.
@Test
public void testLimitAndRemaining() {
final RewardViewModel vm = new RewardViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Pair<String, String>> limitAndRemainingTextViewTextTest = TestSubscriber.create();
vm.outputs.limitAndRemainingTextViewText().subscribe(limitAndRemainingTextViewTextTest);
final TestSubscriber<Boolean> limitAndRemainingTextViewIsHiddenTest = TestSubscriber.create();
vm.outputs.limitAndRemainingTextViewIsHidden().subscribe(limitAndRemainingTextViewIsHiddenTest);
// When reward is limited, quantity should be shown.
final Reward limitedReward = RewardFactory.reward().toBuilder().limit(10).remaining(5).build();
vm.inputs.projectAndReward(project, limitedReward);
limitAndRemainingTextViewTextTest.assertValue(Pair.create("10", "5"));
limitAndRemainingTextViewIsHiddenTest.assertValue(false);
// When reward's limit has been reached, don't show quantity.
vm.inputs.projectAndReward(project, RewardFactory.limitReached());
limitAndRemainingTextViewIsHiddenTest.assertValues(false, true);
// When reward has no limit, don't show quantity (distinct until changed).
vm.inputs.projectAndReward(project, RewardFactory.reward());
limitAndRemainingTextViewIsHiddenTest.assertValues(false, true);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewModelTest method testSelectedHeaderAndOverlay.
@Test
public void testSelectedHeaderAndOverlay() {
final RewardViewModel vm = new RewardViewModel(environment());
final TestSubscriber<Boolean> selectedHeaderIsHidden = TestSubscriber.create();
vm.outputs.selectedHeaderIsHidden().subscribe(selectedHeaderIsHidden);
final TestSubscriber<Boolean> selectedOverlayIsHidden = TestSubscriber.create();
vm.outputs.selectedOverlayIsHidden().subscribe(selectedOverlayIsHidden);
final Project backedProject = ProjectFactory.backedProject();
vm.inputs.projectAndReward(backedProject, backedProject.backing().reward());
selectedHeaderIsHidden.assertValue(false);
selectedOverlayIsHidden.assertValue(false);
vm.inputs.projectAndReward(backedProject, RewardFactory.reward());
selectedHeaderIsHidden.assertValues(false, true);
selectedOverlayIsHidden.assertValues(false, true);
}
Aggregations