Search in sources :

Example 86 with MockCurrentUser

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

the class ActivityFeedViewModelTest method testErroredBackings_whenLoggedIn.

@Test
public void testErroredBackings_whenLoggedIn() {
    final CurrentUserType currentUser = new MockCurrentUser();
    final User initialUser = UserFactory.user();
    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();
    setUpEnvironment(environment);
    this.erroredBackings.assertValueCount(1);
    this.vm.inputs.refresh();
    this.erroredBackings.assertValueCount(2);
    this.segmentTrack.assertValue(EventName.PAGE_VIEWED.getEventName());
}
Also used : User(com.kickstarter.models.User) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) Environment(com.kickstarter.libs.Environment) CurrentUserType(com.kickstarter.libs.CurrentUserType) Observable(rx.Observable) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

MockCurrentUser (com.kickstarter.libs.MockCurrentUser)86 Test (org.junit.Test)85 CurrentUserType (com.kickstarter.libs.CurrentUserType)43 Environment (com.kickstarter.libs.Environment)39 Project (com.kickstarter.models.Project)31 User (com.kickstarter.models.User)31 MockApiClient (com.kickstarter.mock.services.MockApiClient)29 NonNull (androidx.annotation.NonNull)26 Intent (android.content.Intent)16 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)12 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)12 Backing (com.kickstarter.models.Backing)11 NotNull (org.jetbrains.annotations.NotNull)11 MessageThread (com.kickstarter.models.MessageThread)10 TestSubscriber (rx.observers.TestSubscriber)10 ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)7 MockBooleanPreference (com.kickstarter.libs.preferences.MockBooleanPreference)6 Message (com.kickstarter.models.Message)6 DiscoveryParams (com.kickstarter.services.DiscoveryParams)6 IntentKey (com.kickstarter.ui.IntentKey)6