use of com.kickstarter.services.apiresponses.MessageThreadEnvelope 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.services.apiresponses.MessageThreadEnvelope 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.services.apiresponses.MessageThreadEnvelope 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.services.apiresponses.MessageThreadEnvelope 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);
}
use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testProjectData_ExistingMessages.
@Test
public void testProjectData_ExistingMessages() {
final MessageThread messageThread = MessageThreadFactory.messageThread();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread thread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
this.creatorNameTextViewText.assertValues(messageThread.project().creator().name());
this.projectNameTextViewText.assertValues(messageThread.project().name());
this.projectNameToolbarTextViewText.assertValues(messageThread.project().name());
}
Aggregations