Search in sources :

Example 16 with CurrentUserType

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

the class ThanksViewModelTest method testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySignedUp.

@Test
public void testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySignedUp() {
    final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
    final User user = UserFactory.user().toBuilder().gamesNewsletter(true).build();
    final CurrentUserType currentUser = new MockCurrentUser(user);
    final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
    final ThanksViewModel vm = new ThanksViewModel(environment);
    final TestSubscriber<Void> showGamesNewsletterDialogTest = new TestSubscriber<>();
    vm.outputs.showGamesNewsletterDialog().subscribe(showGamesNewsletterDialogTest);
    final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    showGamesNewsletterDialogTest.assertValueCount(0);
}
Also used : Project(com.kickstarter.models.Project) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) User(com.kickstarter.models.User) MockBooleanPreference(com.kickstarter.libs.preferences.MockBooleanPreference) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 17 with CurrentUserType

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

the class ThanksViewModelTest method testThanksViewModel_dontShowGamesNewsletterDialogIfRootCategoryIsNotGames.

@Test
public void testThanksViewModel_dontShowGamesNewsletterDialogIfRootCategoryIsNotGames() {
    final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
    final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
    final CurrentUserType currentUser = new MockCurrentUser(user);
    final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
    final ThanksViewModel vm = new ThanksViewModel(environment);
    final TestSubscriber<Void> showGamesNewsletterDialogTest = new TestSubscriber<>();
    vm.outputs.showGamesNewsletterDialog().subscribe(showGamesNewsletterDialogTest);
    final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.ceramicsCategory()).build();
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    showGamesNewsletterDialogTest.assertValueCount(0);
}
Also used : Project(com.kickstarter.models.Project) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) User(com.kickstarter.models.User) MockBooleanPreference(com.kickstarter.libs.preferences.MockBooleanPreference) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 18 with CurrentUserType

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

the class ThanksViewModelTest method testThanksViewModel_dontShowRatingDialogIfGamesNewsletterWillDisplay.

@Test
public void testThanksViewModel_dontShowRatingDialogIfGamesNewsletterWillDisplay() {
    final MockBooleanPreference hasSeenAppRatingPreference = new MockBooleanPreference(false);
    final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
    final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
    final CurrentUserType currentUser = new MockCurrentUser(user);
    final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenAppRatingPreference(hasSeenAppRatingPreference).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
    final ThanksViewModel vm = new ThanksViewModel(environment);
    final TestSubscriber<Void> showRatingDialogTest = new TestSubscriber<>();
    vm.outputs.showRatingDialog().subscribe(showRatingDialogTest);
    final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
    vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
    showRatingDialogTest.assertValueCount(0);
}
Also used : Project(com.kickstarter.models.Project) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) User(com.kickstarter.models.User) MockBooleanPreference(com.kickstarter.libs.preferences.MockBooleanPreference) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

CurrentUserType (com.kickstarter.libs.CurrentUserType)18 Environment (com.kickstarter.libs.Environment)18 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)18 Test (org.junit.Test)18 TestSubscriber (rx.observers.TestSubscriber)17 Intent (android.content.Intent)11 Project (com.kickstarter.models.Project)11 User (com.kickstarter.models.User)11 MockBooleanPreference (com.kickstarter.libs.preferences.MockBooleanPreference)6 KSRobolectricTestCase (com.kickstarter.KSRobolectricTestCase)4 ProjectFactory (com.kickstarter.factories.ProjectFactory)4 UserFactory (com.kickstarter.factories.UserFactory)4 IntentKey (com.kickstarter.ui.IntentKey)4 Newsletter (com.kickstarter.ui.data.Newsletter)4 ConfigFactory (com.kickstarter.factories.ConfigFactory)3 KoalaEvent (com.kickstarter.libs.KoalaEvent)3 MockApiClient (com.kickstarter.services.MockApiClient)3 List (java.util.List)3 Pair (android.util.Pair)2 ApiClientType (com.kickstarter.services.ApiClientType)2