Search in sources :

Example 1 with DiscoverEnvelope

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

the class ProfileViewModelTest method testProfileViewModel_EmitsProjects.

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

        @Override
        @NonNull
        public Observable<DiscoverEnvelope> fetchProjects(@NonNull final DiscoveryParams params) {
            return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(Collections.singletonList(ProjectFactory.project())));
        }
    };
    final Environment env = environment().toBuilder().apiClient(apiClient).build();
    final ProfileViewModel.ViewModel vm = new ProfileViewModel.ViewModel(env);
    final TestSubscriber<List<Project>> projects = new TestSubscriber<>();
    vm.outputs.projects().subscribe(projects);
    koalaTest.assertValues(KoalaEvent.PROFILE_VIEW_MY, KoalaEvent.VIEWED_PROFILE);
    projects.assertValueCount(1);
}
Also used : DiscoverEnvelope(com.kickstarter.services.apiresponses.DiscoverEnvelope) MockApiClient(com.kickstarter.services.MockApiClient) NonNull(android.support.annotation.NonNull) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) List(java.util.List) DiscoveryParams(com.kickstarter.services.DiscoveryParams) ApiClientType(com.kickstarter.services.ApiClientType) Test(org.junit.Test)

Aggregations

NonNull (android.support.annotation.NonNull)1 Environment (com.kickstarter.libs.Environment)1 ApiClientType (com.kickstarter.services.ApiClientType)1 DiscoveryParams (com.kickstarter.services.DiscoveryParams)1 MockApiClient (com.kickstarter.services.MockApiClient)1 DiscoverEnvelope (com.kickstarter.services.apiresponses.DiscoverEnvelope)1 List (java.util.List)1 Test (org.junit.Test)1 TestSubscriber (rx.observers.TestSubscriber)1