use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testSendMessageButtonIsEnabled.
@Test
public void testSendMessageButtonIsEnabled() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
this.sendMessageButtonIsEnabled.assertNoValues();
this.vm.inputs.messageEditTextChanged("hello");
this.sendMessageButtonIsEnabled.assertValues(true);
this.vm.inputs.messageEditTextChanged("");
this.sendMessageButtonIsEnabled.assertValues(true, false);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackButton_IsVisible.
@Test
public void testBackButton_IsVisible() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(backerModalContextIntent(BackingFactory.backing(), ProjectFactory.project()));
// Back button is visible if navigating from backer modal view.
this.backButtonIsGone.assertValues(false);
this.closeButtonIsGone.assertValues(true);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testGoBack.
@Test
public void testGoBack() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
this.vm.inputs.backOrCloseButtonClicked();
this.goBack.assertValueCount(1);
}
use of com.kickstarter.libs.MockCurrentUser 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.libs.MockCurrentUser 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);
}
Aggregations