Skip to content

Commit

Permalink
Add unit test for DropInConfigDataGenerator
Browse files Browse the repository at this point in the history
COAND-967
  • Loading branch information
OscarSpruit committed Aug 23, 2024
1 parent 100482b commit 2822f86
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.adyen.checkout.dropin.internal.ui

import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParams
import com.adyen.checkout.components.core.internal.ui.model.AnalyticsParamsLevel
import com.adyen.checkout.core.Environment
import com.adyen.checkout.dropin.internal.ui.model.DropInParams
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.util.Locale

internal class DropInConfigDataGeneratorTest {

private lateinit var dropInConfigDataGenerator: DropInConfigDataGenerator

@BeforeEach
fun beforeEach() {
dropInConfigDataGenerator = DropInConfigDataGenerator()
}

@Test
fun `when generating config data, then fields are correctly mapped`() {
val result = dropInConfigDataGenerator.generate(createDropInParams())

val expected = mapOf(
"skipPaymentMethodList" to "false",
"openFirstStoredPaymentMethod" to "true",
"isRemovingStoredPaymentMethodsEnabled" to "true",
)
assertEquals(expected, result)
}

private fun createDropInParams() = DropInParams(
shopperLocale = Locale.US,
environment = Environment.TEST,
clientKey = "clientKey",
analyticsParams = AnalyticsParams(AnalyticsParamsLevel.ALL, "clientKey"),
amount = null,
showPreselectedStoredPaymentMethod = true,
skipListWhenSinglePaymentMethod = false,
isRemovingStoredPaymentMethodsEnabled = true,
additionalDataForDropInService = null,
overriddenPaymentMethodInformation = emptyMap(),
)
}

0 comments on commit 2822f86

Please sign in to comment.