-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize DefaultVerticalModeFormInteractor
- Loading branch information
1 parent
a997c6d
commit b0a1c79
Showing
4 changed files
with
214 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...rc/test/java/com/stripe/android/paymentelement/embedded/form/FormActivityViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.stripe.android.paymentelement.embedded.form | ||
|
||
import androidx.lifecycle.SavedStateHandle | ||
import com.google.common.truth.Truth.assertThat | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadata | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory | ||
import com.stripe.android.model.PaymentMethodCode | ||
import com.stripe.android.paymentelement.embedded.EmbeddedSelectionHolder | ||
import com.stripe.android.utils.FakeLinkConfigurationCoordinator | ||
import com.stripe.android.utils.NullCardAccountRangeRepositoryFactory | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
internal class FormActivityViewModelTest { | ||
|
||
@Test | ||
fun `viewmodel initializes interactor correctly`() = runTest { | ||
val paymentMethodMetadata = PaymentMethodMetadataFactory.create() | ||
|
||
val selectedPaymentMethodCode = "klarna" | ||
|
||
val viewModel = createViewModel(paymentMethodMetadata, selectedPaymentMethodCode) | ||
|
||
assertThat(viewModel.formInteractor.state.value.formArguments.paymentMethodCode).isEqualTo("klarna") | ||
} | ||
|
||
private fun createViewModel( | ||
paymentMethodMetadata: PaymentMethodMetadata, | ||
paymentMethodCode: PaymentMethodCode | ||
): FormActivityViewModel { | ||
val savedStateHandle = SavedStateHandle() | ||
val selectionHolder = EmbeddedSelectionHolder(savedStateHandle) | ||
|
||
return FormActivityViewModel( | ||
paymentMethodMetadata = paymentMethodMetadata, | ||
selectedPaymentMethodCode = paymentMethodCode, | ||
cardAccountRangeRepositoryFactory = NullCardAccountRangeRepositoryFactory, | ||
selectionHolder = selectionHolder, | ||
linkConfigurationCoordinator = FakeLinkConfigurationCoordinator() | ||
) | ||
} | ||
} |