use of com.kickstarter.services.ApolloClientType in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testShouldShowEmptySavedView_isTrue_whenUserHasNoSavedProjects.
@Test
public void testShouldShowEmptySavedView_isTrue_whenUserHasNoSavedProjects() {
final CurrentUserType currentUser = new MockCurrentUser();
final ApolloClientType apiClient = new MockApolloClient() {
@Override
@NonNull
public Observable<DiscoverEnvelope> getProjects(@NonNull final DiscoveryParams params, final String cursor) {
if (params.isSavedProjects()) {
return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(new ArrayList<>()));
} else {
return super.getProjects(params, cursor);
}
}
};
final Environment environment = environment().toBuilder().apolloClient(apiClient).currentUser(currentUser).build();
setUpEnvironment(environment);
// Initial home all projects params.
setUpInitialHomeAllProjectsParams();
this.hasProjects.assertValue(true);
this.shouldShowEmptySavedView.assertValue(false);
// Login.
logUserIn(currentUser);
// New projects load.
this.hasProjects.assertValues(true, true, true, true);
this.shouldShowEmptySavedView.assertValues(false);
// Saved projects params.
this.vm.inputs.paramsFromActivity(DiscoveryParams.builder().starred(1).build());
// Projects are cleared, new projects load with updated params.
this.hasProjects.assertValues(true, true, true, true, false, false);
this.shouldShowEmptySavedView.assertValues(false, true);
}
Aggregations