-
Notifications
You must be signed in to change notification settings - Fork 629
/
CollectBankAccountForPaymentSheetLauncherTest.kt
69 lines (60 loc) · 2.47 KB
/
CollectBankAccountForPaymentSheetLauncherTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.stripe.android.paymentsheet
import androidx.activity.result.ActivityResultLauncher
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountContract
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class CollectBankAccountForPaymentSheetLauncherTest {
private val mockHostActivityLauncher =
mock<ActivityResultLauncher<CollectBankAccountContract.Args>>()
private val launcher = CollectBankAccountForPaymentSheetLauncher(mockHostActivityLauncher)
@Test
fun `presentWithPaymentIntent - launches CollectBankAccountActivity with correct arguments`() {
launcher.presentWithPaymentIntent(
publishableKey = PUBLISHABLE_KEY,
stripeAccountId = STRIPE_ACCOUNT_ID,
clientSecret = CLIENT_SECRET,
configuration = CONFIGURATION
)
verify(mockHostActivityLauncher).launch(
CollectBankAccountContract.Args.ForPaymentIntent(
publishableKey = PUBLISHABLE_KEY,
stripeAccountId = STRIPE_ACCOUNT_ID,
clientSecret = CLIENT_SECRET,
configuration = CONFIGURATION,
attachToIntent = false
)
)
}
@Test
fun `presentWithSetupIntent - launches CollectBankAccountActivity with correct arguments`() {
launcher.presentWithSetupIntent(
publishableKey = PUBLISHABLE_KEY,
stripeAccountId = STRIPE_ACCOUNT_ID,
clientSecret = CLIENT_SECRET,
configuration = CONFIGURATION
)
verify(mockHostActivityLauncher).launch(
CollectBankAccountContract.Args.ForSetupIntent(
publishableKey = PUBLISHABLE_KEY,
stripeAccountId = STRIPE_ACCOUNT_ID,
clientSecret = CLIENT_SECRET,
configuration = CONFIGURATION,
attachToIntent = false
)
)
}
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
)
}
}