@@ -35,6 +35,7 @@ import com.adyen.checkout.components.core.OrderRequest
35
35
import com.adyen.checkout.components.core.PaymentComponentData
36
36
import com.adyen.checkout.components.core.PaymentMethod
37
37
import com.adyen.checkout.components.core.internal.PaymentObserverRepository
38
+ import com.adyen.checkout.components.core.internal.analytics.ErrorEvent
38
39
import com.adyen.checkout.components.core.internal.analytics.GenericEvents
39
40
import com.adyen.checkout.components.core.internal.analytics.TestAnalyticsManager
40
41
import com.adyen.checkout.components.core.internal.ui.model.CommonComponentParamsMapper
@@ -532,6 +533,33 @@ internal class DefaultCashAppPayDelegateTest(
532
533
analyticsManager.assertLastEventNotEquals(expectedEvent)
533
534
}
534
535
536
+ @Test
537
+ fun `when state is declined, then an error is tracked` () = runTest {
538
+ delegate.initialize(CoroutineScope (UnconfinedTestDispatcher ()))
539
+
540
+ delegate.cashAppPayStateDidChange(CashAppPayState .Declined )
541
+
542
+ val expectedEvent = GenericEvents .error(
543
+ component = TEST_PAYMENT_METHOD_TYPE ,
544
+ event = ErrorEvent .THIRD_PARTY
545
+ )
546
+ analyticsManager.assertLastEventEquals(expectedEvent)
547
+ }
548
+
549
+ @Test
550
+ fun `when state is exception, then an error is tracked` () = runTest {
551
+ delegate.initialize(CoroutineScope (UnconfinedTestDispatcher ()))
552
+ val exception = RuntimeException (" Stub!" )
553
+
554
+ delegate.cashAppPayStateDidChange(CashAppPayState .CashAppPayExceptionState (exception))
555
+
556
+ val expectedEvent = GenericEvents .error(
557
+ component = TEST_PAYMENT_METHOD_TYPE ,
558
+ event = ErrorEvent .THIRD_PARTY
559
+ )
560
+ analyticsManager.assertLastEventEquals(expectedEvent)
561
+ }
562
+
535
563
@Test
536
564
fun `when delegate is cleared then analytics manager is cleared` () {
537
565
delegate.initialize(CoroutineScope (UnconfinedTestDispatcher ()))
0 commit comments