Skip to content

Commit

Permalink
Fixes tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmuvi-stripe committed Aug 12, 2022
1 parent ed20493 commit 1b8acd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
@@ -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
Expand All @@ -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
Expand All @@ -42,11 +40,6 @@ import kotlin.test.Test
@ExperimentalCoroutinesApi
@RunWith(RobolectricTestRunner::class)
class USBankAccountFormViewModelTest {
private val lpmRepository =
LpmRepository(LpmRepository.LpmRepositoryArguments(ApplicationProvider.getApplicationContext<Application>().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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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"
}
}

0 comments on commit 1b8acd4

Please sign in to comment.