@@ -30,7 +30,6 @@ import org.junit.Assert.*
3030import org.junit.Before
3131import org.junit.Test
3232import org.mockito.Mock
33- import org.mockito.Mockito.mock
3433import org.mockito.MockitoAnnotations
3534import java.util.concurrent.TimeUnit
3635
@@ -75,12 +74,6 @@ class CtaTest {
7574 assertTrue(testee.pixelShownParameters().isEmpty())
7675 }
7776
78- @Test
79- fun whenCtaIsSurveyReturnNullDialogCta () {
80- val testee = HomePanelCta .Survey (Survey (" abc" , " http://example.com" , 1 , Survey .Status .SCHEDULED ))
81- assertNull(testee.createDialogCta(mock(FragmentActivity ::class .java)))
82- }
83-
8477 @Test
8578 fun whenCtaIsAddWidgetAutoReturnEmptyOkParameters () {
8679 val testee = HomePanelCta .AddWidgetAuto
@@ -99,11 +92,6 @@ class CtaTest {
9992 assertTrue(testee.pixelShownParameters().isEmpty())
10093 }
10194
102- @Test
103- fun whenCtaIsAddWidgetAutoReturnNullDialogCta () {
104- val testee = HomePanelCta .AddWidgetAuto
105- assertNull(testee.createDialogCta(mock(FragmentActivity ::class .java)))
106- }
10795
10896 @Test
10997 fun whenCtaIsAddWidgetInstructionsReturnEmptyOkParameters () {
@@ -123,12 +111,6 @@ class CtaTest {
123111 assertTrue(testee.pixelShownParameters().isEmpty())
124112 }
125113
126- @Test
127- fun whenCtaIsAddWidgetInstructionsReturnNullDialogCta () {
128- val testee = HomePanelCta .AddWidgetInstructions
129- assertNull(testee.createDialogCta(mock(FragmentActivity ::class .java)))
130- }
131-
132114 @Test
133115 fun whenCtaIsBubbleTypeReturnCorrectCancelParameters () {
134116 val testee = DaxBubbleCta .DaxIntroCta (mockOnboardingStore, mockAppInstallStore)
@@ -163,6 +145,49 @@ class CtaTest {
163145 assertEquals(expectedValue, value[CTA_SHOWN ])
164146 }
165147
148+ @Test
149+ fun whenAddCtaToHistoryThenReturnCorrectValue () {
150+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(null )
151+ whenever(mockAppInstallStore.installTimestamp).thenReturn(System .currentTimeMillis())
152+
153+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
154+ val value = testee.addCtaToHistory(" test" )
155+ assertEquals(" test:0" , value)
156+ }
157+
158+ @Test
159+ fun whenAddCtaToHistoryOnDay3ThenReturnCorrectValue () {
160+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(null )
161+ whenever(mockAppInstallStore.installTimestamp).thenReturn(System .currentTimeMillis() - TimeUnit .DAYS .toMillis(3 ))
162+
163+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
164+ val value = testee.addCtaToHistory(" test" )
165+ assertEquals(" test:3" , value)
166+ }
167+
168+ @Test
169+ fun whenAddCtaToHistoryOnDay4ThenReturn3AsDayValue () {
170+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(null )
171+ whenever(mockAppInstallStore.installTimestamp).thenReturn(System .currentTimeMillis() - TimeUnit .DAYS .toMillis(4 ))
172+
173+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
174+ val value = testee.addCtaToHistory(" test" )
175+ assertEquals(" test:3" , value)
176+ }
177+
178+ @Test
179+ fun whenAddCtaToHistoryContainsHistoryThenConcatenateNewValue () {
180+ val ctaHistory = " s:0-t:1"
181+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(ctaHistory)
182+ whenever(mockAppInstallStore.installTimestamp).thenReturn(System .currentTimeMillis() - TimeUnit .DAYS .toMillis(1 ))
183+
184+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
185+ val value = testee.addCtaToHistory(" test" )
186+ val expectedValue = " $ctaHistory -test:1"
187+
188+ assertEquals(expectedValue, value)
189+ }
190+
166191 @Test
167192 fun whenCtaIsBubbleTypeThenConcatenateJourneyStoredValueInPixel () {
168193 val existingJourney = " s:0-t:1"
@@ -175,6 +200,21 @@ class CtaTest {
175200 assertEquals(expectedValue, value[CTA_SHOWN ])
176201 }
177202
203+ @Test
204+ fun whenCanSendPixelAndCtaNotPartOfHistoryThenReturnTrue () {
205+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(" s:0" )
206+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
207+ assertTrue(testee.canSendShownPixel())
208+ }
209+
210+ @Test
211+ fun whenCanSendPixelAndCtaIsPartOfHistoryThenReturnFalse () {
212+ whenever(mockOnboardingStore.onboardingDialogJourney).thenReturn(" e:0" )
213+
214+ val testee = DaxBubbleCta .DaxEndCta (mockOnboardingStore, mockAppInstallStore)
215+ assertFalse(testee.canSendShownPixel())
216+ }
217+
178218 @Test
179219 fun whenCtaIsDialogTypeReturnCorrectCancelParameters () {
180220 val testee = DaxDialogCta .DaxSerpCta (mockOnboardingStore, mockAppInstallStore)
@@ -235,7 +275,7 @@ class CtaTest {
235275 }
236276
237277 @Test
238- fun whenTwoMajorTrackersBlockedReturnThemWithMultipleString () {
278+ fun whenTwoMajorTrackersBlockedReturnThemWithZeroString () {
239279 val trackers = listOf (
240280 TrackingEvent (" facebook.com" , " facebook.com" , blocked = true , entity = TestEntity (" Facebook" , " Facebook" , 9.0 ), categories = null ),
241281 TrackingEvent (" other.com" , " other.com" , blocked = true , entity = TestEntity (" Other" , " Other" , 9.0 ), categories = null )
0 commit comments