use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class KSRobolectricTestCase method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
final MockTrackingClient testTrackingClient = new MockTrackingClient();
koalaTest = new TestSubscriber<>();
testTrackingClient.eventNames.subscribe(koalaTest);
environment = application().component().environment().toBuilder().apiClient(new MockApiClient()).currentConfig(new MockCurrentConfig()).webClient(new MockWebClient()).koala(new Koala(testTrackingClient)).build();
}
use of com.kickstarter.services.MockApiClient 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()).subscribe(resultTest);
resultTest.assertValues(DiscoveryParams.builder().build());
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class ProjectIntentMapperTest method testProject_doesNotEmitFromHttpsProjectUri.
@Test
public void testProject_doesNotEmitFromHttpsProjectUri() {
final Uri uri = Uri.parse("https://www.kickstarter.com/projects/1186238668/skull-graphic-tee");
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
final TestSubscriber<Project> resultTest = TestSubscriber.create();
ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
resultTest.assertNoValues();
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class ProjectIntentMapperTest method testProject_emitsTwiceFromProjectExtra.
@Test
public void testProject_emitsTwiceFromProjectExtra() {
final Project project = ProjectFactory.project();
final Intent intent = new Intent().putExtra(IntentKey.PROJECT, project);
final TestSubscriber<Project> resultTest = TestSubscriber.create();
ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
resultTest.assertValueCount(2);
}
use of com.kickstarter.services.MockApiClient in project android-oss by kickstarter.
the class LoginViewModelTest method testLoginTfaChallenge.
@Test
public void testLoginTfaChallenge() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> login(@NonNull final String email, @NonNull final String password) {
return Observable.error(ApiExceptionFactory.tfaRequired());
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final LoginViewModel vm = new LoginViewModel(environment);
final TestSubscriber<Void> tfaChallenge = new TestSubscriber<>();
vm.errors.tfaChallenge().subscribe(tfaChallenge);
final TestSubscriber<Void> loginSuccess = new TestSubscriber<>();
vm.outputs.loginSuccess().subscribe(loginSuccess);
vm.inputs.email("hello@kickstarter.com");
vm.inputs.password("danisawesome");
vm.inputs.loginClick();
loginSuccess.assertNoValues();
tfaChallenge.assertValueCount(1);
}
Aggregations