use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class DiscoveryViewModelTest method testDrawerMenuIcon_afterLogInRefreshAndLogOut.
@Test
public void testDrawerMenuIcon_afterLogInRefreshAndLogOut() {
final MockCurrentUser currentUser = new MockCurrentUser();
this.vm = new DiscoveryViewModel.ViewModel(environment().toBuilder().currentUser(currentUser).build());
this.vm.getOutputs().drawerMenuIcon().subscribe(this.drawerMenuIcon);
this.drawerMenuIcon.assertValue(R.drawable.ic_menu);
currentUser.refresh(UserFactory.user().toBuilder().unreadMessagesCount(4).build());
this.drawerMenuIcon.assertValues(R.drawable.ic_menu, R.drawable.ic_menu_indicator);
currentUser.refresh(UserFactory.user().toBuilder().erroredBackingsCount(2).build());
this.drawerMenuIcon.assertValues(R.drawable.ic_menu, R.drawable.ic_menu_indicator, R.drawable.ic_menu_error_indicator);
currentUser.refresh(UserFactory.user().toBuilder().unreadMessagesCount(4).unseenActivityCount(3).erroredBackingsCount(2).build());
this.drawerMenuIcon.assertValues(R.drawable.ic_menu, R.drawable.ic_menu_indicator, R.drawable.ic_menu_error_indicator);
currentUser.logout();
this.drawerMenuIcon.assertValues(R.drawable.ic_menu, R.drawable.ic_menu_indicator, R.drawable.ic_menu_error_indicator, R.drawable.ic_menu);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class LoginToutViewModelTest method facebookLogin_error.
@Test
public void facebookLogin_error() {
final MockCurrentUser currentUser = new MockCurrentUser();
final Environment environment = environment().toBuilder().currentUser(currentUser).apiClient(new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> loginWithFacebook(@NonNull final String accessToken) {
return Observable.error(new Throwable("error"));
}
}).build();
setUpEnvironment(environment, LoginReason.DEFAULT);
this.currentUser.assertValuesAndClear(null);
this.vm.inputs.facebookLoginClick(null, Arrays.asList("public_profile", "user_friends", "email"));
this.vm.facebookAccessToken.onNext("token");
this.currentUser.assertNoValues();
this.finishWithSuccessfulResult.assertNoValues();
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class LoginToutViewModelTest method facebookLogin_success.
@Test
public void facebookLogin_success() {
final MockCurrentUser currentUser = new MockCurrentUser();
final Environment environment = environment().toBuilder().currentUser(currentUser).build();
setUpEnvironment(environment, LoginReason.DEFAULT);
this.currentUser.assertValuesAndClear(null);
this.vm.inputs.facebookLoginClick(null, Arrays.asList("public_profile", "user_friends", "email"));
this.vm.facebookAccessToken.onNext("token");
this.currentUser.assertValueCount(1);
this.finishWithSuccessfulResult.assertValueCount(1);
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
use of com.kickstarter.libs.MockCurrentUser 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();
setUpEnvironment(environment);
final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
this.vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
this.showGamesNewsletterDialogTest.assertValueCount(0);
}
use of com.kickstarter.libs.MockCurrentUser 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 Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenAppRatingPreference(hasSeenAppRatingPreference).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
setUpEnvironment(environment);
this.vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
this.showRatingDialogTest.assertValueCount(0);
}
Aggregations