use of rx.schedulers.TestScheduler in project android-oss by kickstarter.
the class SearchViewModelTest method testPopularRefTags.
@Test
public void testPopularRefTags() {
final TestScheduler scheduler = new TestScheduler();
final List<Project> projects = Arrays.asList(ProjectFactory.allTheWayProject(), ProjectFactory.almostCompletedProject(), ProjectFactory.backedProject());
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<DiscoverEnvelope> fetchProjects(@NonNull final DiscoveryParams params) {
return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(projects));
}
};
final Environment env = environment().toBuilder().scheduler(scheduler).apiClient(apiClient).build();
setUpEnvironment(env);
// populate search and overcome debounce
this.vm.inputs.search("");
scheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS);
this.vm.inputs.projectClicked(projects.get(2));
this.goToRefTag.assertValues(RefTag.searchPopular());
this.goToProject.assertValues(projects.get(2));
}
Aggregations