-
Notifications
You must be signed in to change notification settings - Fork 990
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBL-1278: Analytics on late pledge checkout screen (#2001)
- Loading branch information
Showing
5 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/src/test/java/com/kickstarter/viewmodels/LatePledgeCheckoutViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.kickstarter.viewmodels | ||
|
||
import com.kickstarter.KSRobolectricTestCase | ||
import com.kickstarter.libs.Environment | ||
import com.kickstarter.libs.utils.EventName | ||
import com.kickstarter.mock.factories.ProjectDataFactory | ||
import com.kickstarter.mock.factories.ProjectFactory | ||
import com.kickstarter.mock.factories.RewardFactory | ||
import com.kickstarter.mock.factories.ShippingRuleFactory | ||
import com.kickstarter.viewmodels.projectpage.LatePledgeCheckoutViewModel | ||
import org.junit.Test | ||
|
||
class LatePledgeCheckoutViewModelTest : KSRobolectricTestCase() { | ||
|
||
private lateinit var viewModel: LatePledgeCheckoutViewModel | ||
|
||
private fun setUpEnvironment(environment: Environment) { | ||
viewModel = LatePledgeCheckoutViewModel.Factory(environment).create(LatePledgeCheckoutViewModel::class.java) | ||
} | ||
|
||
@Test | ||
fun `test send PageViewed event`() { | ||
setUpEnvironment(environment()) | ||
|
||
val rw = RewardFactory.rewardWithShipping() | ||
val project = ProjectFactory.project().toBuilder().rewards(listOf(rw)).build() | ||
val addOns = listOf(rw, rw, rw) | ||
val rule = ShippingRuleFactory.germanyShippingRule() | ||
val shipAmount = 3.0 | ||
val totalAmount = 300.0 | ||
val bonusAmount = 5.0 | ||
|
||
val projectData = ProjectDataFactory.project(project = project) | ||
|
||
viewModel.userRewardSelection(rw) | ||
viewModel.sendPageViewedEvent( | ||
projectData, | ||
addOns, | ||
rule, | ||
shipAmount, | ||
totalAmount, | ||
bonusAmount | ||
) | ||
|
||
this.segmentTrack.assertValue(EventName.PAGE_VIEWED.eventName) | ||
} | ||
|
||
@Test | ||
fun `test send CTAClicked event`() { | ||
setUpEnvironment(environment()) | ||
|
||
val rw = RewardFactory.rewardWithShipping() | ||
val project = ProjectFactory.project().toBuilder().rewards(listOf(rw)).build() | ||
val addOns = listOf(rw, rw, rw) | ||
val rule = ShippingRuleFactory.germanyShippingRule() | ||
val shipAmount = 3.0 | ||
val totalAmount = 300.0 | ||
val bonusAmount = 5.0 | ||
|
||
val projectData = ProjectDataFactory.project(project = project) | ||
viewModel.userRewardSelection(rw) | ||
viewModel.sendSubmitCTAEvent( | ||
projectData, | ||
addOns, | ||
rule, | ||
shipAmount, | ||
totalAmount, | ||
bonusAmount | ||
) | ||
|
||
this.segmentTrack.assertValue(EventName.CTA_CLICKED.eventName) | ||
} | ||
} |