use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage() {
final Project project = ProjectFactory.project();
final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
final CurrentUserType currentUser = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
this.setUpEnvironment(environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
this.vm.inputs.projectButtonClicked();
this.startProjectActivity.assertValueCount(1);
assertEquals(this.startProjectActivity.getOnNextEvents().get(0).first, project);
assertEquals(this.startProjectActivity.getOnNextEvents().get(0).second, RefTag.dashboard());
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testThanksViewModel_whenFeatureFlagOn_shouldEmitProjectPage() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
setUpEnvironment(environment);
final Project project = ProjectFactory.project();
final CheckoutData checkoutData = CheckoutDataFactory.Companion.checkoutData(3L, 20.0, 30.0);
final PledgeData pledgeData = PledgeData.Companion.with(PledgeFlowContext.NEW_PLEDGE, ProjectDataFactory.Companion.project(project), RewardFactory.reward(), Collections.emptyList(), null);
final Intent intent = new Intent().putExtra(IntentKey.CHECKOUT_DATA, checkoutData).putExtra(IntentKey.PLEDGE_DATA, pledgeData).putExtra(IntentKey.PROJECT, project);
this.vm.intent(intent);
this.vm.inputs.projectCardViewHolderClicked(project);
final Pair<Project, RefTag> projectPageParams = this.startProjectTest.getOnNextEvents().get(0);
assertEquals(projectPageParams.first, project);
assertEquals(projectPageParams.second, RefTag.thanks());
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testUpdateViewModel_whenFeatureFlagOn_shouldEmitProjectPage() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment);
final TestSubscriber<Pair<Uri, RefTag>> startProjectActivity = new TestSubscriber<>();
vm.outputs.startProjectActivity().subscribe(startProjectActivity);
// Start the intent with a project and update.
vm.intent(this.defaultIntent);
final String url = "https://www.kickstarter.com/projects/smithsonian/smithsonian-anthology-of-hip-hop-and-rap";
final Request projectRequest = new Request.Builder().url(url).build();
vm.inputs.goToProjectRequest(projectRequest);
startProjectActivity.assertValueCount(1);
assertEquals(startProjectActivity.getOnNextEvents().get(0).first, Uri.parse(url));
assertEquals(startProjectActivity.getOnNextEvents().get(0).second, RefTag.update());
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_featureEnabled.
@Test
public void testShouldShowEditorial_featureEnabled() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature, @NotNull final ExperimentData experimentData) {
return true;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
setUpEnvironment(environment);
setUpInitialHomeAllProjectsParams();
this.shouldShowEditorial.assertValue(Editorial.LIGHTS_ON);
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_whenOptimizelyInitializationDelay.
@Test
public void testShouldShowEditorial_whenOptimizelyInitializationDelay() {
final Environment environment = environment().toBuilder().currentUser(new MockCurrentUser()).optimizely(new MockExperimentsClientType() {
int enabledCount;
@Override
public boolean isFeatureEnabled(@NonNull final OptimizelyFeature.Key feature, @NonNull final ExperimentData experimentData) {
if (enabledCount == 0) {
enabledCount += 1;
return false;
} else {
return true;
}
}
}).build();
setUpEnvironment(environment);
setUpInitialHomeAllProjectsParams();
this.shouldShowEditorial.assertValue(null);
this.vm.optimizelyReady();
this.shouldShowEditorial.assertValues(null, Editorial.LIGHTS_ON);
}
Aggregations