Search in sources :

Example 1 with PledgeData

use of com.kickstarter.ui.data.PledgeData in project android-oss by kickstarter.

the class ThanksViewModelTest method testThanksViewModel_startProject.

@Test
public void testThanksViewModel_startProject() {
    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());
}
Also used : Project(com.kickstarter.models.Project) CheckoutData(com.kickstarter.ui.data.CheckoutData) PledgeData(com.kickstarter.ui.data.PledgeData) Intent(android.content.Intent) RefTag(com.kickstarter.libs.RefTag) Test(org.junit.Test)

Example 2 with PledgeData

use of com.kickstarter.ui.data.PledgeData in project android-oss by kickstarter.

the class ThanksViewModelTest method testTracking_whenCheckoutDataAndPledgeDataExtrasPresent.

@Test
public void testTracking_whenCheckoutDataAndPledgeDataExtrasPresent() {
    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.segmentTrack.assertValue(EventName.PAGE_VIEWED.getEventName());
}
Also used : Project(com.kickstarter.models.Project) CheckoutData(com.kickstarter.ui.data.CheckoutData) PledgeData(com.kickstarter.ui.data.PledgeData) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with PledgeData

use of com.kickstarter.ui.data.PledgeData 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());
}
Also used : Project(com.kickstarter.models.Project) CheckoutData(com.kickstarter.ui.data.CheckoutData) Environment(com.kickstarter.libs.Environment) PledgeData(com.kickstarter.ui.data.PledgeData) Intent(android.content.Intent) RefTag(com.kickstarter.libs.RefTag) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) IntentKey(com.kickstarter.ui.IntentKey) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)3 Project (com.kickstarter.models.Project)3 CheckoutData (com.kickstarter.ui.data.CheckoutData)3 PledgeData (com.kickstarter.ui.data.PledgeData)3 Test (org.junit.Test)3 RefTag (com.kickstarter.libs.RefTag)2 Environment (com.kickstarter.libs.Environment)1 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)1 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)1 IntentKey (com.kickstarter.ui.IntentKey)1 NotNull (org.jetbrains.annotations.NotNull)1