Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynewstrom-stripe committed Oct 25, 2024
1 parent f127432 commit c37f4f8
Showing 1 changed file with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.stripe.android.ApiKeyFixtures
import com.stripe.android.PaymentAuthConfig
import com.stripe.android.core.networking.ApiRequest
import com.stripe.android.model.PaymentIntentFixtures
import com.stripe.android.model.Stripe3ds2AuthResult
import com.stripe.android.model.StripeIntent
import com.stripe.android.networking.StripeRepository
import com.stripe.android.stripe3ds2.init.ui.StripeUiCustomization
Expand All @@ -30,18 +29,11 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.robolectric.RobolectricTestRunner
import kotlin.test.assertNotNull

@RunWith(RobolectricTestRunner::class)
class Stripe3ds2TransactionViewModelTest {
// FragmentScenario is needed to provide SavedStateRegistryOwner required
// by Stripe3ds2TransactionViewModelFactory
private val scenario = launchFragmentInContainer(initialState = Lifecycle.State.CREATED) {
TestFragment()
}

private val context = ApplicationProvider.getApplicationContext<Application>()
private val stripeRepository = mock<StripeRepository>()

Expand All @@ -56,13 +48,6 @@ class Stripe3ds2TransactionViewModelTest {
@Test
fun `When nextActionData contains publishableKey then it is used to start 3ds2 auth`() =
runTest {
whenever(
stripeRepository.start3ds2Auth(
any(),
eq(ApiRequest.Options(ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY))
)
).thenReturn(Result.success(mock<Stripe3ds2AuthResult>()))

val viewModel = createViewModel()
viewModel.start3ds2Flow()

Expand All @@ -75,13 +60,6 @@ class Stripe3ds2TransactionViewModelTest {
@Test
fun `When nextActionData does not contain publishableKey then default key is used in 3ds2`() =
runTest {
whenever(
stripeRepository.start3ds2Auth(
any(),
eq(ApiRequest.Options(ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY))
)
).thenReturn(Result.success(mock<Stripe3ds2AuthResult>()))

val nextActionData = PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2.nextActionData
as StripeIntent.NextActionData.SdkData.Use3DS2
val viewModel = createViewModel(
Expand All @@ -99,6 +77,11 @@ class Stripe3ds2TransactionViewModelTest {

@Test
fun `Stripe3ds2TransactionViewModel gets initialized`() {
// FragmentScenario is needed to provide SavedStateRegistryOwner required
// by Stripe3ds2TransactionViewModelFactory
val scenario = launchFragmentInContainer(initialState = Lifecycle.State.CREATED) {
TestFragment()
}
scenario.onFragment { fragment ->
val factory = Stripe3ds2TransactionViewModelFactory { ARGS }

Expand Down

0 comments on commit c37f4f8

Please sign in to comment.