Search in sources :

Example 1 with CurrentConfigType

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

Example 2 with CurrentConfigType

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

Example 3 with CurrentConfigType

use of com.kickstarter.libs.CurrentConfigType in project android-oss by kickstarter.

the class FacebookConfimationViewModelTest method testToggleSendNewsLetter_isNotChecked.

@Test
public void testToggleSendNewsLetter_isNotChecked() {
    final CurrentConfigType currentConfig = new MockCurrentConfig();
    currentConfig.config(ConfigFactory.config().toBuilder().countryCode("US").build());
    final Environment environment = environment().toBuilder().currentConfig(currentConfig).build();
    this.vm = new FacebookConfirmationViewModel.ViewModel(environment);
    this.vm.outputs.sendNewslettersIsChecked().subscribe(this.sendNewslettersIsChecked);
    this.sendNewslettersIsChecked.assertValue(false);
    this.vm.inputs.sendNewslettersClick(true);
    this.vm.inputs.sendNewslettersClick(false);
    this.sendNewslettersIsChecked.assertValues(false, true, false);
}
Also used : MockCurrentConfig(com.kickstarter.mock.MockCurrentConfig) CurrentConfigType(com.kickstarter.libs.CurrentConfigType) Environment(com.kickstarter.libs.Environment) Test(org.junit.Test)

Example 4 with CurrentConfigType

use of com.kickstarter.libs.CurrentConfigType 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);
}
Also used : MockCurrentConfig(com.kickstarter.mock.MockCurrentConfig) KSCurrency(com.kickstarter.libs.KSCurrency) MockCurrentConfig(com.kickstarter.mock.MockCurrentConfig) Config(com.kickstarter.libs.Config) CurrentConfigType(com.kickstarter.libs.CurrentConfigType)

Aggregations

CurrentConfigType (com.kickstarter.libs.CurrentConfigType)4 Config (com.kickstarter.libs.Config)3 Environment (com.kickstarter.libs.Environment)3 Test (org.junit.Test)3 MockCurrentConfig (com.kickstarter.mock.MockCurrentConfig)2 Project (com.kickstarter.models.Project)2 Reward (com.kickstarter.models.Reward)2 KSCurrency (com.kickstarter.libs.KSCurrency)1