Search in sources :

Example 6 with MockApolloClient

use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.

the class DiscoveryFragmentViewModelTest method testShouldShowEmptySavedView_isFalse_whenUserHasSavedProjects.

@Test
public void testShouldShowEmptySavedView_isFalse_whenUserHasSavedProjects() {
    final CurrentUserType currentUser = new MockCurrentUser();
    final Environment environment = environment().toBuilder().apolloClient(new MockApolloClient()).currentUser(currentUser).build();
    setUpEnvironment(environment);
    // Initial home all projects params.
    setUpInitialHomeAllProjectsParams();
    this.hasProjects.assertValue(true);
    this.shouldShowEmptySavedView.assertValue(false);
    // Login.
    logUserIn(currentUser);
    // New projects load.
    this.hasProjects.assertValues(true, true, true, true);
    this.shouldShowEmptySavedView.assertValues(false);
    // Saved projects params.
    this.vm.inputs.paramsFromActivity(DiscoveryParams.builder().starred(1).build());
    // New projects load with updated params.
    this.hasProjects.assertValues(true, true, true, true, true, true);
    this.shouldShowEmptySavedView.assertValues(false);
}
Also used : MockApolloClient(com.kickstarter.mock.services.MockApolloClient) Environment(com.kickstarter.libs.Environment) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 7 with MockApolloClient

use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.

the class DiscoveryIntentMapperTest method emitsFromDiscoveryUri.

@Test
public void emitsFromDiscoveryUri() {
    final Uri uri = Uri.parse("https://www.kickstarter.com/discover");
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
    DiscoveryIntentMapper.params(intent, new MockApiClient(), new MockApolloClient()).subscribe(resultTest);
    resultTest.assertValues(DiscoveryParams.builder().build());
}
Also used : MockApolloClient(com.kickstarter.mock.services.MockApolloClient) MockApiClient(com.kickstarter.mock.services.MockApiClient) Intent(android.content.Intent) DiscoveryParams(com.kickstarter.services.DiscoveryParams) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

MockApolloClient (com.kickstarter.mock.services.MockApolloClient)7 Test (org.junit.Test)7 DiscoveryParams (com.kickstarter.services.DiscoveryParams)6 Intent (android.content.Intent)5 MockApiClient (com.kickstarter.mock.services.MockApiClient)5 Uri (android.net.Uri)4 CurrentUserType (com.kickstarter.libs.CurrentUserType)2 Environment (com.kickstarter.libs.Environment)2 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)2 NonNull (androidx.annotation.NonNull)1 ApolloClientType (com.kickstarter.services.ApolloClientType)1 DiscoverEnvelope (com.kickstarter.services.apiresponses.DiscoverEnvelope)1 ArrayList (java.util.ArrayList)1