From 1b8acd404c94089063410c7140900f3dbcb38a25 Mon Sep 17 00:00:00 2001 From: Carlos Munoz Date: Fri, 12 Aug 2022 10:52:22 +0200 Subject: [PATCH] Fixes tests. --- ...tBankAccountForPaymentSheetLauncherTest.kt | 19 +++++++++++-------- .../ach/USBankAccountFormViewModelTest.kt | 17 +++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/CollectBankAccountForPaymentSheetLauncherTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/CollectBankAccountForPaymentSheetLauncherTest.kt index ce5871a8b49..2dea55edeff 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/CollectBankAccountForPaymentSheetLauncherTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/CollectBankAccountForPaymentSheetLauncherTest.kt @@ -20,15 +20,16 @@ class CollectBankAccountForPaymentSheetLauncherTest { @Test fun `presentWithPaymentIntent - launches CollectBankAccountActivity with correct arguments`() { launcher.presentWithPaymentIntent( - PUBLISHABLE_KEY, - CLIENT_SECRET, - CONFIGURATION + publishableKey = PUBLISHABLE_KEY, + stripeAccountId = STRIPE_ACCOUNT_ID, + clientSecret = CLIENT_SECRET, + configuration = CONFIGURATION ) verify(mockHostActivityLauncher).launch( CollectBankAccountContract.Args.ForPaymentIntent( publishableKey = PUBLISHABLE_KEY, - stripeAccountId = stripeAccountId, + stripeAccountId = STRIPE_ACCOUNT_ID, clientSecret = CLIENT_SECRET, configuration = CONFIGURATION, attachToIntent = false @@ -39,15 +40,16 @@ class CollectBankAccountForPaymentSheetLauncherTest { @Test fun `presentWithSetupIntent - launches CollectBankAccountActivity with correct arguments`() { launcher.presentWithSetupIntent( - PUBLISHABLE_KEY, - CLIENT_SECRET, - CONFIGURATION + publishableKey = PUBLISHABLE_KEY, + stripeAccountId = STRIPE_ACCOUNT_ID, + clientSecret = CLIENT_SECRET, + configuration = CONFIGURATION ) verify(mockHostActivityLauncher).launch( CollectBankAccountContract.Args.ForSetupIntent( publishableKey = PUBLISHABLE_KEY, - stripeAccountId = stripeAccountId, + stripeAccountId = STRIPE_ACCOUNT_ID, clientSecret = CLIENT_SECRET, configuration = CONFIGURATION, attachToIntent = false @@ -58,6 +60,7 @@ class CollectBankAccountForPaymentSheetLauncherTest { companion object { private const val CLIENT_SECRET = "client_secret" private const val PUBLISHABLE_KEY = "publishableKey" + private const val STRIPE_ACCOUNT_ID = "stripe_account_id" private val CONFIGURATION = CollectBankAccountConfiguration.USBankAccount( name = "Carlos", email = null diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt index 1f044e854e1..fd5e0e8cbf8 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt @@ -1,6 +1,5 @@ package com.stripe.android.paymentsheet.paymentdatacollection.ach -import android.app.Application import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import androidx.test.core.app.ApplicationProvider @@ -21,7 +20,6 @@ import com.stripe.android.paymentsheet.model.PaymentIntentClientSecret import com.stripe.android.paymentsheet.model.PaymentSelection import com.stripe.android.paymentsheet.paymentdatacollection.FormFragmentArguments import com.stripe.android.ui.core.Amount -import com.stripe.android.ui.core.forms.resources.LpmRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.stateIn @@ -42,11 +40,6 @@ import kotlin.test.Test @ExperimentalCoroutinesApi @RunWith(RobolectricTestRunner::class) class USBankAccountFormViewModelTest { - private val lpmRepository = - LpmRepository(LpmRepository.LpmRepositoryArguments(ApplicationProvider.getApplicationContext().resources)).apply { - this.forceUpdate(listOf(PaymentMethod.Type.Card.code, PaymentMethod.Type.USBankAccount.code), null) - } - private val usBankAccount = lpmRepository.fromCode(PaymentMethod.Type.USBankAccount.code)!! private val defaultArgs = USBankAccountFormViewModel.Args( formArgs = FormFragmentArguments( @@ -128,7 +121,7 @@ class USBankAccountFormViewModelTest { viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.NameAndEmailCollection) - verify(collectBankAccountLauncher).presentWithPaymentIntent(any(), any(), any()) + verify(collectBankAccountLauncher).presentWithPaymentIntent(any(), any(), any(), any()) } @Test @@ -222,7 +215,7 @@ class USBankAccountFormViewModelTest { viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.NameAndEmailCollection) - verify(collectBankAccountLauncher).presentWithPaymentIntent(any(), any(), any()) + verify(collectBankAccountLauncher).presentWithPaymentIntent(any(), any(), any(), any()) } @Test @@ -299,7 +292,10 @@ class USBankAccountFormViewModelTest { private fun createViewModel( args: USBankAccountFormViewModel.Args = defaultArgs ): USBankAccountFormViewModel { - val paymentConfiguration = PaymentConfiguration(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY) + val paymentConfiguration = PaymentConfiguration( + ApiKeyFixtures.FAKE_PUBLISHABLE_KEY, + STRIPE_ACCOUNT_ID + ) return USBankAccountFormViewModel( args = args, application = ApplicationProvider.getApplicationContext(), @@ -366,5 +362,6 @@ class USBankAccountFormViewModelTest { const val MERCHANT_NAME = "merchantName" const val CUSTOMER_NAME = "Jenny Rose" const val CUSTOMER_EMAIL = "email@email.com" + const val STRIPE_ACCOUNT_ID = "stripe_account_id" } }