use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackingInfo_NoBacking.
@Test
public void testBackingInfo_NoBacking() {
final Project project = ProjectFactory.project().toBuilder().isBacking(false).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).backing(null).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.error(ApiExceptionFactory.badRequestException());
}
};
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.backingAndProject.assertNoValues();
this.backingInfoViewIsGone.assertValues(true);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testSuccessfullyMarkedAsRead.
@Test
public void testSuccessfullyMarkedAsRead() {
final MessageThread messageThread = MessageThreadFactory.messageThread();
final MockApiClient apiClient = new MockApiClient() {
@NonNull
@Override
public Observable<MessageThread> markAsRead(@NonNull final MessageThread thread) {
return Observable.just(messageThread);
}
};
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).apiClient(apiClient).build());
this.vm.intent(messagesContextIntent(messageThread));
this.successfullyMarkedAsRead.assertValueCount(1);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackButton_IsGone.
@Test
public void testBackButton_IsGone() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
// Back button is gone if navigating from non-backer modal view.
this.backButtonIsGone.assertValues(true);
this.closeButtonIsGone.assertValues(false);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testRecyclerViewBottomPadding.
@Test
public void testRecyclerViewBottomPadding() {
final int appBarTotalScrolLRange = 327;
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(MessageThreadFactory.messageThread()));
// View initially loaded with a 0 (expanded) offset.
this.vm.inputs.appBarOffset(0);
this.vm.inputs.appBarTotalScrollRange(appBarTotalScrolLRange);
// Only initial bottom padding emits.
this.recyclerViewDefaultBottomPadding.assertNoValues();
this.recyclerViewInitialBottomPadding.assertValues(appBarTotalScrolLRange);
// User scrolls.
this.vm.inputs.appBarOffset(-30);
this.vm.inputs.appBarTotalScrollRange(appBarTotalScrolLRange);
// Default padding emits, initial padding does not emit again.
this.recyclerViewDefaultBottomPadding.assertValueCount(1);
this.recyclerViewInitialBottomPadding.assertValues(appBarTotalScrolLRange);
// User scrolls.
this.vm.inputs.appBarOffset(20);
this.vm.inputs.appBarTotalScrollRange(appBarTotalScrolLRange);
// Padding does not change.
this.recyclerViewDefaultBottomPadding.assertValueCount(1);
this.recyclerViewInitialBottomPadding.assertValues(appBarTotalScrolLRange);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackingAndProject_Participant.
@Test
public void testBackingAndProject_Participant() {
final Project project = ProjectFactory.project().toBuilder().isBacking(false).build();
final Backing backing = BackingFactory.backing().toBuilder().project(project).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).backing(backing).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread messageThread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope());
}
@Override
@NonNull
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.just(backing);
}
};
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.backingAndProject.assertValues(Pair.create(backing, backing.project()));
this.backingInfoViewIsGone.assertValues(false);
}
Aggregations