use of com.kickstarter.ui.data.Newsletter in project android-oss by kickstarter.
the class SettingsViewModelTest method testSettingsViewModel_sendWeeklyNewsletter.
@Test
public void testSettingsViewModel_sendWeeklyNewsletter() {
final User user = UserFactory.user().toBuilder().weeklyNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
final SettingsViewModel vm = new SettingsViewModel(environment);
final TestSubscriber<User> currentUserTest = new TestSubscriber<>();
currentUser.observable().subscribe(currentUserTest);
final TestSubscriber<Newsletter> showOptInPromptTest = new TestSubscriber<>();
vm.outputs.showOptInPrompt().subscribe(showOptInPromptTest);
currentUserTest.assertValues(user);
koalaTest.assertValues("Settings View");
vm.inputs.sendWeeklyNewsletter(true);
koalaTest.assertValues("Settings View", "Newsletter Subscribe");
currentUserTest.assertValues(user, user.toBuilder().weeklyNewsletter(true).build());
vm.inputs.sendWeeklyNewsletter(false);
koalaTest.assertValues("Settings View", "Newsletter Subscribe", "Newsletter Unsubscribe");
currentUserTest.assertValues(user, user.toBuilder().weeklyNewsletter(true).build(), user);
showOptInPromptTest.assertNoValues();
}
use of com.kickstarter.ui.data.Newsletter in project android-oss by kickstarter.
the class SettingsViewModelTest method testSettingsViewModel_sendGamesNewsletter.
@Test
public void testSettingsViewModel_sendGamesNewsletter() {
final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
final SettingsViewModel vm = new SettingsViewModel(environment);
final TestSubscriber<User> currentUserTest = new TestSubscriber<>();
currentUser.observable().subscribe(currentUserTest);
final TestSubscriber<Newsletter> showOptInPromptTest = new TestSubscriber<>();
vm.outputs.showOptInPrompt().subscribe(showOptInPromptTest);
currentUserTest.assertValues(user);
koalaTest.assertValues("Settings View");
vm.inputs.sendGamesNewsletter(true);
koalaTest.assertValues("Settings View", "Newsletter Subscribe");
currentUserTest.assertValues(user, user.toBuilder().gamesNewsletter(true).build());
vm.inputs.sendGamesNewsletter(false);
koalaTest.assertValues("Settings View", "Newsletter Subscribe", "Newsletter Unsubscribe");
currentUserTest.assertValues(user, user.toBuilder().gamesNewsletter(true).build(), user);
showOptInPromptTest.assertNoValues();
}
use of com.kickstarter.ui.data.Newsletter in project android-oss by kickstarter.
the class SettingsViewModelTest method testSettingsViewModel_sendPromoNewsletter.
@Test
public void testSettingsViewModel_sendPromoNewsletter() {
final User user = UserFactory.user().toBuilder().promoNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
final SettingsViewModel vm = new SettingsViewModel(environment);
final TestSubscriber<User> currentUserTest = new TestSubscriber<>();
currentUser.observable().subscribe(currentUserTest);
final TestSubscriber<Newsletter> showOptInPromptTest = new TestSubscriber<>();
vm.outputs.showOptInPrompt().subscribe(showOptInPromptTest);
currentUserTest.assertValues(user);
koalaTest.assertValues("Settings View");
vm.inputs.sendPromoNewsletter(true);
koalaTest.assertValues("Settings View", "Newsletter Subscribe");
currentUserTest.assertValues(user, user.toBuilder().promoNewsletter(true).build());
vm.inputs.sendPromoNewsletter(false);
koalaTest.assertValues("Settings View", "Newsletter Subscribe", "Newsletter Unsubscribe");
currentUserTest.assertValues(user, user.toBuilder().promoNewsletter(true).build(), user);
showOptInPromptTest.assertNoValues();
}
use of com.kickstarter.ui.data.Newsletter in project android-oss by kickstarter.
the class SettingsViewModelTest method testSettingsViewModel_sendHappeningNewsletter.
@Test
public void testSettingsViewModel_sendHappeningNewsletter() {
final User user = UserFactory.user().toBuilder().happeningNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
final SettingsViewModel vm = new SettingsViewModel(environment);
final TestSubscriber<User> currentUserTest = new TestSubscriber<>();
currentUser.observable().subscribe(currentUserTest);
final TestSubscriber<Newsletter> showOptInPromptTest = new TestSubscriber<>();
vm.outputs.showOptInPrompt().subscribe(showOptInPromptTest);
currentUserTest.assertValues(user);
koalaTest.assertValues("Settings View");
vm.inputs.sendHappeningNewsletter(true);
koalaTest.assertValues("Settings View", "Newsletter Subscribe");
currentUserTest.assertValues(user, user.toBuilder().happeningNewsletter(true).build());
vm.inputs.sendHappeningNewsletter(false);
koalaTest.assertValues("Settings View", "Newsletter Subscribe", "Newsletter Unsubscribe");
currentUserTest.assertValues(user, user.toBuilder().happeningNewsletter(true).build(), user);
showOptInPromptTest.assertNoValues();
}
Aggregations