Search in sources :

Example 11 with MockExperimentsClientType

use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.

the class DiscoveryFragmentViewModelTest method testStartProjectActivity_whenFeatureFlagEnabled_shouldEmitProjectPageActivity.

@Test
public void testStartProjectActivity_whenFeatureFlagEnabled_shouldEmitProjectPageActivity() {
    final CurrentUserType currentUser = new MockCurrentUser();
    final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {

        @Override
        public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
            return true;
        }
    };
    this.setUpEnvironment(this.environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
    // Load initial params and root categories from activity.
    setUpInitialHomeAllProjectsParams();
    // Click on project
    final Project project = ProjectFactory.project();
    this.vm.inputs.projectCardViewHolderClicked(project);
    this.startProjectActivity.assertValueCount(1);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).first, project);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).second, RefTag.discovery());
    this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CARD_CLICKED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
Also used : Project(com.kickstarter.models.Project) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

MockCurrentUser (com.kickstarter.libs.MockCurrentUser)11 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)11 Test (org.junit.Test)11 NotNull (org.jetbrains.annotations.NotNull)10 Environment (com.kickstarter.libs.Environment)6 CurrentUserType (com.kickstarter.libs.CurrentUserType)5 Project (com.kickstarter.models.Project)5 ExperimentData (com.kickstarter.libs.utils.ExperimentData)3 NonNull (androidx.annotation.NonNull)2 DiscoveryParams (com.kickstarter.services.DiscoveryParams)2 IntentKey (com.kickstarter.ui.IntentKey)2 Intent (android.content.Intent)1 Pair (android.util.Pair)1 RefTag (com.kickstarter.libs.RefTag)1 MockApiClient (com.kickstarter.mock.services.MockApiClient)1 DiscoverEnvelope (com.kickstarter.services.apiresponses.DiscoverEnvelope)1 ProjectStatsEnvelope (com.kickstarter.services.apiresponses.ProjectStatsEnvelope)1 ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)1 CheckoutData (com.kickstarter.ui.data.CheckoutData)1 PledgeData (com.kickstarter.ui.data.PledgeData)1