use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.
the class DiscoveryIntentMapperTest method emitsFromParamsExtra.
@Test
public void emitsFromParamsExtra() {
final DiscoveryParams params = DiscoveryParams.builder().build();
final Intent intent = new Intent().putExtra(IntentKey.DISCOVERY_PARAMS, params);
final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
DiscoveryIntentMapper.params(intent, new MockApiClient(), new MockApolloClient()).subscribe(resultTest);
resultTest.assertValues(params);
}
use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.
the class DiscoveryIntentMapperTest method emitsFromDiscoveryCategoryUri.
@Test
public void emitsFromDiscoveryCategoryUri() {
final Uri uri = Uri.parse("https://www.kickstarter.com/discover/categories/music");
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.assertValueCount(1);
}
use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.
the class DiscoveryIntentMapperTest method emitsFromDiscoveryLocationUri.
@Test
public void emitsFromDiscoveryLocationUri() {
final Uri uri = Uri.parse("https://www.kickstarter.com/discover/places/sydney-au");
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.assertValueCount(1);
}
use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.
the class DiscoveryIntentMapperTest method emitsFromAdvancedCategoryIdAndLocationIdUri.
@Test
public void emitsFromAdvancedCategoryIdAndLocationIdUri() {
final Uri uri = Uri.parse("https://www.kickstarter.com/discover/advanced?category_id=1&location_id=1");
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.assertValueCount(1);
}
use of com.kickstarter.mock.services.MockApolloClient in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testShouldShowEmptySavedView_isTrue_whenUserHasNoSavedProjects.
@Test
public void testShouldShowEmptySavedView_isTrue_whenUserHasNoSavedProjects() {
final CurrentUserType currentUser = new MockCurrentUser();
final ApolloClientType apiClient = new MockApolloClient() {
@Override
@NonNull
public Observable<DiscoverEnvelope> getProjects(@NonNull final DiscoveryParams params, final String cursor) {
if (params.isSavedProjects()) {
return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(new ArrayList<>()));
} else {
return super.getProjects(params, cursor);
}
}
};
final Environment environment = environment().toBuilder().apolloClient(apiClient).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());
// Projects are cleared, new projects load with updated params.
this.hasProjects.assertValues(true, true, true, true, false, false);
this.shouldShowEmptySavedView.assertValues(false, true);
}
Aggregations