use of com.kickstarter.mock.services.MockApiClient 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.MockApiClient 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.MockApiClient 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.MockApiClient 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.MockApiClient in project android-oss by kickstarter.
the class DiscoveryViewModelTest method testShowSnackBar_whenIntentFromDeepLinkSuccessResponse_showErrorMessage.
@Test
public void testShowSnackBar_whenIntentFromDeepLinkSuccessResponse_showErrorMessage() {
final String url = "https://*.kickstarter.com/profile/verify_email";
final Intent intentWithUrl = new Intent().setData(Uri.parse(url));
final ErrorEnvelope errorEnvelope = ErrorEnvelope.builder().httpCode(403).errorMessages(Collections.singletonList("expired")).build();
final ApiException apiException = ApiExceptionFactory.apiError(errorEnvelope);
final MockApiClient mockApiClient = new MockApiClient() {
@NonNull
@Override
public Observable<EmailVerificationEnvelope> verifyEmail(@NonNull final String token) {
return Observable.error(apiException);
}
};
final Environment mockedClientEnvironment = environment().toBuilder().apiClient(mockApiClient).build();
this.vm = new DiscoveryViewModel.ViewModel(mockedClientEnvironment);
this.vm.getOutputs().showSuccessMessage().subscribe(this.showSuccessMessage);
this.vm.getOutputs().showErrorMessage().subscribe(this.showErrorMessage);
this.vm.intent(intentWithUrl);
this.showSuccessMessage.assertNoValues();
this.showErrorMessage.assertValue("expired");
}
Aggregations