Search in sources :

Example 1 with CommentsEnvelope

use of com.kickstarter.services.apiresponses.CommentsEnvelope in project android-oss by kickstarter.

the class CommentsViewModelTest method testCommentsViewModel_EmptyState.

@Test
public void testCommentsViewModel_EmptyState() {
    final ApiClientType apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<CommentsEnvelope> fetchComments(@NonNull final Update update) {
            return Observable.empty();
        }
    };
    final Environment env = environment().toBuilder().apiClient(apiClient).build();
    final CommentsViewModel vm = new CommentsViewModel(env);
    final TestSubscriber<CommentsData> commentsData = new TestSubscriber<>();
    vm.outputs.commentsData().subscribe(commentsData);
    // Start the view model with an update.
    vm.intent(new Intent().putExtra(IntentKey.UPDATE, UpdateFactory.update()));
    // Only Viewed Comments event should fire.
    koalaTest.assertValues(KoalaEvent.VIEWED_COMMENTS);
    commentsData.assertNoValues();
}
Also used : CommentsEnvelope(com.kickstarter.services.apiresponses.CommentsEnvelope) CommentsData(com.kickstarter.ui.adapters.data.CommentsData) MockApiClient(com.kickstarter.services.MockApiClient) NonNull(android.support.annotation.NonNull) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) Intent(android.content.Intent) Update(com.kickstarter.models.Update) ApiClientType(com.kickstarter.services.ApiClientType) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)1 NonNull (android.support.annotation.NonNull)1 Environment (com.kickstarter.libs.Environment)1 Update (com.kickstarter.models.Update)1 ApiClientType (com.kickstarter.services.ApiClientType)1 MockApiClient (com.kickstarter.services.MockApiClient)1 CommentsEnvelope (com.kickstarter.services.apiresponses.CommentsEnvelope)1 CommentsData (com.kickstarter.ui.adapters.data.CommentsData)1 Test (org.junit.Test)1 TestSubscriber (rx.observers.TestSubscriber)1