use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class TwoFactorViewModelTest method testTwoFactorViewModel_CodeMismatchError.
@Test
public void testTwoFactorViewModel_CodeMismatchError() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<AccessTokenEnvelope> login(@NonNull final String email, @NonNull final String password, @NonNull final String code) {
return Observable.error(ApiExceptionFactory.tfaFailed());
}
};
final Environment environment = environment().toBuilder().apiClient(apiClient).build();
final Intent intent = new Intent();
intent.putExtra(IntentKey.EMAIL, "gina@kickstarter.com");
intent.putExtra(IntentKey.PASSWORD, "hello");
intent.putExtra(IntentKey.FACEBOOK_LOGIN, false);
intent.putExtra(IntentKey.FACEBOOK_TOKEN, "");
this.vm = new TwoFactorViewModel.ViewModel(environment);
this.vm.intent(intent);
this.vm.outputs.tfaSuccess().subscribe(this.tfaSuccess);
this.vm.outputs.formSubmitting().subscribe(this.formSubmitting);
this.vm.outputs.tfaCodeMismatchError().subscribe(this.tfaCodeMismatchError);
this.vm.inputs.code("88888");
this.vm.inputs.loginClick();
this.formSubmitting.assertValues(true, false);
this.tfaSuccess.assertNoValues();
this.tfaCodeMismatchError.assertValueCount(1);
this.segmentTrack.assertValue(EventName.PAGE_VIEWED.getEventName());
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class CreatorDashboardViewModelTest method testProjectName_whenMultipleProjects.
@Test
public void testProjectName_whenMultipleProjects() {
final Project project1 = ProjectFactory.project().toBuilder().name("Best Project 2K19").build();
final Project project2 = ProjectFactory.project();
final List<Project> projects = Arrays.asList(project1, project2);
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
this.vm.intent(new Intent());
this.projectName.assertValue("Best Project 2K19");
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class CreatorDashboardViewModelTest method testProjectSwitcherProjectClickOutput.
@Test
public void testProjectSwitcherProjectClickOutput() {
DateTimeUtils.setCurrentMillisFixed(new DateTime().getMillis());
final Project project1 = ProjectFactory.project();
final Project project2 = ProjectFactory.project();
final List<Project> projects = Arrays.asList(project1, project2);
final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
}
@Override
@NonNull
public Observable<ProjectStatsEnvelope> fetchProjectStats(@NonNull final Project project) {
return Observable.just(projectStatsEnvelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
this.vm.intent(new Intent());
this.vm.inputs.projectSelectionInput(project2);
this.projectDashboardData.assertValues(new ProjectDashboardData(project1, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false), new ProjectDashboardData(project2, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class CreatorDashboardViewModelTest method testProjectDashboardData_whenViewingSingleProjects.
public void testProjectDashboardData_whenViewingSingleProjects() {
final Project project = ProjectFactory.project();
final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<ProjectStatsEnvelope> fetchProjectStats(@NonNull final Project project) {
return Observable.just(projectStatsEnvelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
this.vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
this.projectDashboardData.assertValue(new ProjectDashboardData(project, projectStatsEnvelope, true));
}
use of com.kickstarter.mock.services.MockApiClient in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testSuccessResponseForFetchActivitiesWithCount.
@Test
public void testSuccessResponseForFetchActivitiesWithCount() {
final CurrentUserType currentUser = new MockCurrentUser();
final Activity activity = ActivityFactory.activity();
final MockApiClient apiClient = new MockApiClient() {
@NonNull
@Override
public Observable<ActivityEnvelope> fetchActivities(@Nullable final Integer count) {
return Observable.just(ActivityEnvelopeFactory.activityEnvelope(Collections.singletonList(activity)));
}
};
final Environment env = environment().toBuilder().currentUser(currentUser).apiClient(apiClient).build();
setUpEnvironment(env);
// Load initial params and root categories from activity.
setUpInitialHomeAllProjectsParams();
// Log in.
logUserIn(currentUser);
this.activityTest.assertValueCount(2);
this.activityTest.assertValues(null, activity);
}
Aggregations