use of com.kickstarter.libs.Config 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.libs.Config in project android-oss by kickstarter.
the class RewardViewModelTest method testUsdConversionForNonUSProject.
@Test
public void testUsdConversionForNonUSProject() {
// 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 CA.
final Project project = ProjectFactory.caProject();
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 be shown.
vm.inputs.projectAndReward(project, reward);
usdConversionTextViewText.assertValueCount(1);
usdConversionSectionIsHidden.assertValue(false);
// Set user's country to CA (any country except the US is fine).
currentConfig.config(ConfigFactory.configForCAUser());
// USD conversion should now be hidden.
usdConversionTextViewText.assertValueCount(1);
usdConversionSectionIsHidden.assertValues(false, true);
}
use of com.kickstarter.libs.Config 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.libs.Config in project android-oss by kickstarter.
the class KSCurrencyTest method createKSCurrency.
private static KSCurrency createKSCurrency(final String countryCode) {
final Config config = ConfigFactory.config().toBuilder().countryCode(countryCode).build();
final CurrentConfigType currentConfig = new MockCurrentConfig();
currentConfig.config(config);
return new KSCurrency(currentConfig);
}
Aggregations