use of com.kickstarter.models.MessageThread in project android-oss by kickstarter.
the class MessagesViewModelTest method testCreatorViewingProjectMessages.
@Test
public void testCreatorViewingProjectMessages() {
final User creator = UserFactory.creator().toBuilder().name("Sharon").build();
final User participant = UserFactory.user().toBuilder().name("Timothy").build();
final CurrentUserType currentUser = new MockCurrentUser(creator);
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(ProjectFactory.project().toBuilder().creator(creator).build()).participant(participant).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread thread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messageThread(messageThread).build());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
// Creator name is the project creator, edit text hint is always the participant.
this.creatorNameTextViewText.assertValues(creator.name());
this.messageEditTextHint.assertValues(participant.name());
}
use of com.kickstarter.models.MessageThread in project android-oss by kickstarter.
the class MessageThreadHolderViewModelTest method testMessageThread_HasNoUnreadMessages.
@Test
public void testMessageThread_HasNoUnreadMessages() {
final MessageThread messageThreadWithNoUnread = MessageThreadFactory.messageThread().toBuilder().unreadMessagesCount(0).build();
setUpEnvironment(environment());
// Configure the view model with a message thread with no unread messages.
this.vm.inputs.configureWith(messageThreadWithNoUnread);
this.dateTextViewIsBold.assertValues(false);
this.messageBodyTextIsBold.assertValues(false);
this.participantNameTextViewIsBold.assertValues(false);
this.unreadCountTextViewIsGone.assertValues(true);
this.unreadCountTextViewText.assertValues(NumberUtils.format(messageThreadWithNoUnread.unreadMessagesCount()));
}
use of com.kickstarter.models.MessageThread in project android-oss by kickstarter.
the class MessageThreadHolderViewModelTest method testMessageThread_Clicked.
@Test
public void testMessageThread_Clicked() {
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().id(12345).unreadMessagesCount(1).build();
setUpEnvironment(environment());
this.vm.inputs.configureWith(messageThread);
this.cardViewIsElevated.assertValues(true);
this.dateTextViewIsBold.assertValues(true);
this.messageBodyTextIsBold.assertValues(true);
this.unreadCountTextViewIsGone.assertValues(false);
this.vm.inputs.messageThreadCardViewClicked();
this.cardViewIsElevated.assertValues(true, false);
this.dateTextViewIsBold.assertValues(true, false);
this.messageBodyTextIsBold.assertValues(true, false);
this.unreadCountTextViewIsGone.assertValues(false, true);
}
use of com.kickstarter.models.MessageThread in project android-oss by kickstarter.
the class MessageThreadHolderViewModelTest method testMessageThread_HasUnreadMessages.
@Test
public void testMessageThread_HasUnreadMessages() {
final MessageThread messageThreadWithUnread = MessageThreadFactory.messageThread().toBuilder().unreadMessagesCount(2).build();
setUpEnvironment(environment());
// Configure the view model with a message thread with unread messages.
this.vm.inputs.configureWith(messageThreadWithUnread);
this.dateTextViewIsBold.assertValues(true);
this.messageBodyTextIsBold.assertValues(true);
this.participantNameTextViewIsBold.assertValues(true);
this.unreadCountTextViewIsGone.assertValues(false);
this.unreadCountTextViewText.assertValues(NumberUtils.format(messageThreadWithUnread.unreadMessagesCount()));
}
use of com.kickstarter.models.MessageThread 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();
}
Aggregations