Search in sources :

Example 31 with ApiClientType

use of com.kickstarter.services.ApiClientType 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);
}
Also used : MockApiClient(com.kickstarter.mock.services.MockApiClient) Environment(com.kickstarter.libs.Environment) CurrentUserType(com.kickstarter.libs.CurrentUserType) ApiClientType(com.kickstarter.services.ApiClientType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

ApiClientType (com.kickstarter.services.ApiClientType)31 Test (org.junit.Test)31 Environment (com.kickstarter.libs.Environment)25 MockApiClient (com.kickstarter.mock.services.MockApiClient)19 TestSubscriber (rx.observers.TestSubscriber)18 Intent (android.content.Intent)16 NonNull (androidx.annotation.NonNull)12 MockApiClient (com.kickstarter.services.MockApiClient)12 User (com.kickstarter.models.User)9 NonNull (android.support.annotation.NonNull)8 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)8 AccessTokenEnvelope (com.kickstarter.services.apiresponses.AccessTokenEnvelope)8 Update (com.kickstarter.models.Update)5 CurrentUserType (com.kickstarter.libs.CurrentUserType)4 Project (com.kickstarter.models.Project)3 Nullable (androidx.annotation.Nullable)2 ProjectNotification (com.kickstarter.models.ProjectNotification)2 MessageThreadsEnvelope (com.kickstarter.services.apiresponses.MessageThreadsEnvelope)2 Mailbox (com.kickstarter.ui.data.Mailbox)2 TestScheduler (rx.schedulers.TestScheduler)2