use of com.kickstarter.models.Backing in project android-oss by kickstarter.
the class ViewPledgeViewModelTest method testBackingStatus.
@Test
public void testBackingStatus() {
final Backing backing = BackingFactory.backing();
final ViewPledgeViewModel vm = vm(backing);
final TestSubscriber<String> backingStatusTextViewTest = TestSubscriber.create();
vm.outputs.backingStatus().subscribe(backingStatusTextViewTest);
vm.intent(intent(backing));
backingStatusTextViewTest.assertValue(backing.status());
}
use of com.kickstarter.models.Backing 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.models.Backing 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.models.Backing 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.models.Backing 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