-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update containsVolatileDifferences. (#9933)
- Loading branch information
1 parent
6fa293e
commit 1d4d941
Showing
7 changed files
with
115 additions
and
153 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
40 changes: 40 additions & 0 deletions
40
paymentsheet/src/test/java/com/stripe/android/common/model/CommonConfigurationFactory.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,40 @@ | ||
package com.stripe.android.common.model | ||
|
||
import com.stripe.android.ExperimentalCardBrandFilteringApi | ||
import com.stripe.android.model.CardBrand | ||
import com.stripe.android.paymentsheet.PaymentSheet | ||
import com.stripe.android.paymentsheet.addresselement.AddressDetails | ||
|
||
internal object CommonConfigurationFactory { | ||
@OptIn(ExperimentalCardBrandFilteringApi::class) | ||
fun create( | ||
merchantDisplayName: String = "Example, Inc.", | ||
customer: PaymentSheet.CustomerConfiguration? = null, | ||
googlePay: PaymentSheet.GooglePayConfiguration? = null, | ||
defaultBillingDetails: PaymentSheet.BillingDetails? = null, | ||
shippingDetails: AddressDetails? = null, | ||
allowsDelayedPaymentMethods: Boolean = true, | ||
allowsPaymentMethodsRequiringShippingAddress: Boolean = true, | ||
billingDetailsCollectionConfiguration: PaymentSheet.BillingDetailsCollectionConfiguration = | ||
PaymentSheet.BillingDetailsCollectionConfiguration(), | ||
preferredNetworks: List<CardBrand> = emptyList(), | ||
allowsRemovalOfLastSavedPaymentMethod: Boolean = true, | ||
paymentMethodOrder: List<String> = emptyList(), | ||
externalPaymentMethods: List<String> = emptyList(), | ||
cardBrandAcceptance: PaymentSheet.CardBrandAcceptance = PaymentSheet.CardBrandAcceptance.all(), | ||
): CommonConfiguration = CommonConfiguration( | ||
merchantDisplayName = merchantDisplayName, | ||
customer = customer, | ||
googlePay = googlePay, | ||
defaultBillingDetails = defaultBillingDetails, | ||
shippingDetails = shippingDetails, | ||
allowsDelayedPaymentMethods = allowsDelayedPaymentMethods, | ||
allowsPaymentMethodsRequiringShippingAddress = allowsPaymentMethodsRequiringShippingAddress, | ||
billingDetailsCollectionConfiguration = billingDetailsCollectionConfiguration, | ||
preferredNetworks = preferredNetworks, | ||
allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod, | ||
paymentMethodOrder = paymentMethodOrder, | ||
externalPaymentMethods = externalPaymentMethods, | ||
cardBrandAcceptance = cardBrandAcceptance, | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
paymentsheet/src/test/java/com/stripe/android/common/model/CommonConfigurationTest.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,47 @@ | ||
package com.stripe.android.common.model | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import com.stripe.android.ExperimentalCardBrandFilteringApi | ||
import com.stripe.android.paymentsheet.PaymentSheet | ||
import org.junit.Test | ||
|
||
@OptIn(ExperimentalCardBrandFilteringApi::class) | ||
internal class CommonConfigurationTest { | ||
private val configuration = CommonConfigurationFactory.create() | ||
|
||
@Test | ||
fun `'containVolatileDifferences' should return false when no volatile differences are found`() { | ||
val changedConfiguration = configuration.copy( | ||
merchantDisplayName = "New merchant, Inc.", | ||
) | ||
|
||
assertThat(configuration.containsVolatileDifferences(changedConfiguration)).isFalse() | ||
} | ||
|
||
@Test | ||
fun `'containVolatileDifferences' should return true when volatile differences are found`() { | ||
val configWithCardBrandAcceptanceChanges = configuration.copy( | ||
cardBrandAcceptance = PaymentSheet.CardBrandAcceptance.disallowed( | ||
listOf(PaymentSheet.CardBrandAcceptance.BrandCategory.Visa) | ||
) | ||
) | ||
|
||
assertThat(configuration.containsVolatileDifferences(configWithCardBrandAcceptanceChanges)).isTrue() | ||
|
||
val configWithBillingDetailsChanges = configuration.copy( | ||
defaultBillingDetails = PaymentSheet.BillingDetails( | ||
name = "Jenny Richards", | ||
), | ||
) | ||
|
||
assertThat(configuration.containsVolatileDifferences(configWithBillingDetailsChanges)).isTrue() | ||
|
||
val configWithBillingConfigChanges = configuration.copy( | ||
billingDetailsCollectionConfiguration = PaymentSheet.BillingDetailsCollectionConfiguration( | ||
name = PaymentSheet.BillingDetailsCollectionConfiguration.CollectionMode.Never, | ||
), | ||
) | ||
|
||
assertThat(configuration.containsVolatileDifferences(configWithBillingConfigChanges)).isTrue() | ||
} | ||
} |
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