use of com.kickstarter.mock.services.MockApiClient 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));
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testToolbarIsExpanded_NoMessages.
@Test
public void testToolbarIsExpanded_NoMessages() {
final Backing backing = BackingFactory.backing();
final MessageThreadEnvelope envelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messages(null).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(envelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a backing and project.
this.vm.intent(backerModalContextIntent(backing, ProjectFactory.project()));
this.vm.inputs.messageEditTextIsFocused(true);
// Toolbar stays expanded when keyboard opens and no messages.
this.toolbarIsExpanded.assertNoValues();
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testMessagesEmit.
@Test
public void testMessagesEmit() {
final MessageThreadEnvelope envelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messages(Collections.singletonList(MessageFactory.message())).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread messageThread) {
return Observable.just(envelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
// Messages emit, keyboard not shown.
this.messageList.assertValueCount(1);
this.messageEditTextShouldRequestFocus.assertNoValues();
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testShouldRequestFocus.
@Test
public void testShouldRequestFocus() {
final Backing backing = BackingFactory.backing();
final MessageThreadEnvelope envelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messages(null).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(envelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a backing and project.
this.vm.intent(backerModalContextIntent(backing, ProjectFactory.project()));
this.messageEditTextShouldRequestFocus.assertValueCount(1);
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class MessagesViewModelTest method testToolbarIsExpanded_WithMessages.
@Test
public void testToolbarIsExpanded_WithMessages() {
final Backing backing = BackingFactory.backing();
final MessageThreadEnvelope envelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messages(Collections.singletonList(MessageFactory.message())).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(envelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a backing and project.
this.vm.intent(backerModalContextIntent(backing, ProjectFactory.project()));
this.vm.inputs.messageEditTextIsFocused(true);
// Toolbar collapsed when keyboard opens and there are messages.
this.toolbarIsExpanded.assertValues(false);
}
Aggregations