Search in sources :

Example 56 with MockCurrentUser

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);
}
Also used : MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 57 with MockCurrentUser

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);
}
Also used : MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 58 with MockCurrentUser

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);
}
Also used : MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 59 with MockCurrentUser

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();
}
Also used : MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) MessageThread(com.kickstarter.models.MessageThread) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 60 with MockCurrentUser

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);
}
Also used : MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) Backing(com.kickstarter.models.Backing) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

MockCurrentUser (com.kickstarter.libs.MockCurrentUser)86 Test (org.junit.Test)85 CurrentUserType (com.kickstarter.libs.CurrentUserType)43 Environment (com.kickstarter.libs.Environment)39 Project (com.kickstarter.models.Project)31 User (com.kickstarter.models.User)31 MockApiClient (com.kickstarter.mock.services.MockApiClient)29 NonNull (androidx.annotation.NonNull)26 Intent (android.content.Intent)16 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)12 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)12 Backing (com.kickstarter.models.Backing)11 NotNull (org.jetbrains.annotations.NotNull)11 MessageThread (com.kickstarter.models.MessageThread)10 TestSubscriber (rx.observers.TestSubscriber)10 ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)7 MockBooleanPreference (com.kickstarter.libs.preferences.MockBooleanPreference)6 Message (com.kickstarter.models.Message)6 DiscoveryParams (com.kickstarter.services.DiscoveryParams)6 IntentKey (com.kickstarter.ui.IntentKey)6