From c37f4f887cde92e6bd5e266733a1d89c223e7c15 Mon Sep 17 00:00:00 2001 From: Jay Newstrom Date: Fri, 25 Oct 2024 09:20:04 -0600 Subject: [PATCH] More fixes. --- .../Stripe3ds2TransactionViewModelTest.kt | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/payments-core/src/test/java/com/stripe/android/payments/core/authentication/threeds2/Stripe3ds2TransactionViewModelTest.kt b/payments-core/src/test/java/com/stripe/android/payments/core/authentication/threeds2/Stripe3ds2TransactionViewModelTest.kt index ad2ce044d5b..0a0ea306443 100644 --- a/payments-core/src/test/java/com/stripe/android/payments/core/authentication/threeds2/Stripe3ds2TransactionViewModelTest.kt +++ b/payments-core/src/test/java/com/stripe/android/payments/core/authentication/threeds2/Stripe3ds2TransactionViewModelTest.kt @@ -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 @@ -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() private val stripeRepository = mock() @@ -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())) - val viewModel = createViewModel() viewModel.start3ds2Flow() @@ -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())) - val nextActionData = PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2.nextActionData as StripeIntent.NextActionData.SdkData.Use3DS2 val viewModel = createViewModel( @@ -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 }