use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class DiscoveryIntentMapperTest method emitsFromDiscoveryUri.
@Test
public void emitsFromDiscoveryUri() {
final Uri uri = Uri.parse("https://www.kickstarter.com/discover");
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
DiscoveryIntentMapper.params(intent, new MockApiClient(), new MockApolloClient()).subscribe(resultTest);
resultTest.assertValues(DiscoveryParams.builder().build());
}
use of com.kickstarter.mock.services.MockApiClient 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.mock.services.MockApiClient 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.mock.services.MockApiClient 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);
}
use of com.kickstarter.mock.services.MockApiClient 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());
}
Aggregations