use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testViewPledgeButton_IsVisible_creatorBioModal.
@Test
public void testViewPledgeButton_IsVisible_creatorBioModal() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(creatorBioModalContextIntent(BackingFactory.backing(), ProjectFactory.project()));
// View pledge button is shown when context is from the creator bio modal.
this.viewPledgeButtonIsGone.assertValues(false);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testViewPledgeButton_IsVisible.
@Test
public void testViewPledgeButton_IsVisible() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
// View pledge button is shown when context is from anywhere but the backer modal.
this.viewPledgeButtonIsGone.assertValues(false);
}
use of com.kickstarter.libs.MockCurrentUser 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.libs.MockCurrentUser 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());
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testNoMessages.
@Test
public void testNoMessages() {
final Backing backing = BackingFactory.backing();
final Project project = ProjectFactory.project();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(MessageThreadEnvelopeFactory.empty());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a backing and a project.
this.vm.intent(backerModalContextIntent(backing, project));
// All data except for messages should emit.
this.messageList.assertNoValues();
this.creatorNameTextViewText.assertValues(project.creator().name());
this.backingAndProject.assertValues(Pair.create(backing, project));
}
Aggregations