use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOf1Project.
@Test
public void testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOf1Project() {
final User collaboratorWith1Project = UserFactory.collaborator().toBuilder().memberProjectsCount(1).build();
final CurrentUserType collaborator = new MockCurrentUser(collaboratorWith1Project);
setUpEnvironment(environment().toBuilder().currentUser(collaborator).build());
this.vm.inputs.configureWith(new ProjectDashboardData(ProjectFactory.project(), ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
this.otherProjectsButtonIsGone.assertValue(true);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testMessagesButtonIsGone_whenCurrentUserIsCollaborator.
@Test
public void testMessagesButtonIsGone_whenCurrentUserIsCollaborator() {
final User creator = UserFactory.creator();
final CurrentUserType currentUser = new MockCurrentUser(UserFactory.collaborator());
final Project project = ProjectFactory.project().toBuilder().creator(creator).build();
final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
setUpEnvironment(environment().toBuilder().currentUser(currentUser).build());
this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
// Messages button is gone if current user is not the project creator (e.g. a collaborator).
this.messagesButtonIsGone.assertValue(true);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testUser_LoggedIn_SwipeRefreshed.
@Test
public void testUser_LoggedIn_SwipeRefreshed() {
final CurrentUserType currentUser = new MockCurrentUser();
final User initialUser = UserFactory.user().toBuilder().unseenActivityCount(3).build();
currentUser.login(initialUser, "deadbeef");
final User updatedUser = UserFactory.user();
final Environment environment = this.environment().toBuilder().apiClient(new MockApiClient() {
@NonNull
@Override
public Observable<User> fetchCurrentUser() {
return Observable.just(updatedUser);
}
}).currentUser(currentUser).build();
environment.currentUser().loggedInUser().subscribe(this.user);
setUpEnvironment(environment);
this.surveys.assertValueCount(1);
this.user.assertValues(initialUser, updatedUser);
this.vm.inputs.refresh();
this.surveys.assertValueCount(2);
this.user.assertValues(initialUser, updatedUser);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testUser_whenLoggedInAndResumedWithErroredBackings.
@Test
public void testUser_whenLoggedInAndResumedWithErroredBackings() {
final CurrentUserType currentUser = new MockCurrentUser();
final User initialUser = UserFactory.user().toBuilder().erroredBackingsCount(3).build();
currentUser.login(initialUser, "token");
final User updatedUser = UserFactory.user();
final Environment environment = this.environment().toBuilder().apiClient(new MockApiClient() {
@Override
@NonNull
public Observable<User> fetchCurrentUser() {
return Observable.just(updatedUser);
}
}).currentUser(currentUser).build();
environment.currentUser().loggedInUser().subscribe(this.user);
setUpEnvironment(environment);
this.user.assertValues(initialUser, updatedUser);
this.vm.inputs.resume();
this.user.assertValues(initialUser, updatedUser);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testLoginFlow.
@Test
public void testLoginFlow() {
final ApiClientType apiClient = new MockApiClient();
final CurrentUserType currentUser = new MockCurrentUser();
final Environment environment = this.environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build();
setUpEnvironment(environment);
// Empty activity feed with login button should be shown.
this.loggedOutEmptyStateIsVisible.assertValue(true);
// Login.
this.vm.inputs.emptyActivityFeedLoginClicked(null);
this.goToLogin.assertValueCount(1);
currentUser.refresh(UserFactory.user());
// Empty states are not shown when activities emit on successful login.
this.activityList.assertValueCount(1);
this.loggedOutEmptyStateIsVisible.assertValues(true, false);
this.loggedInEmptyStateIsVisible.assertValue(false);
}
Aggregations