Updated on 2026-08-14
This commit is contained in:
parent
50a384f13d
commit
457e8870a4
7 changed files with 165 additions and 10 deletions
|
|
@ -46,6 +46,7 @@ import com.tangem.features.tangempay.details.impl.R
|
|||
import com.tangem.features.tangempay.entity.*
|
||||
import com.tangem.features.tangempay.model.transformers.*
|
||||
import com.tangem.features.tangempay.navigation.TangemPayAccountDetailsInnerRoute
|
||||
import com.tangem.features.tangempay.tiers.select.TangemPaySelectPlanSource
|
||||
import com.tangem.features.tangempay.utils.*
|
||||
import com.tangem.features.tokendetails.ExpressTransactionsEvent
|
||||
import com.tangem.features.tokendetails.ExpressTransactionsEventListener
|
||||
|
|
@ -151,6 +152,12 @@ internal class TangemPayDetailsModel @Inject constructor(
|
|||
is PaymentAccountStatusValue.Inactive -> uiState.update {
|
||||
stateFactory.getInactiveState(state)
|
||||
}
|
||||
is PaymentAccountStatusValue.AwaitingPlanSelection -> router.replaceAll(
|
||||
TangemPayAccountDetailsInnerRoute.SelectPlan(
|
||||
tariffPlan = state.tariffPlan,
|
||||
source = TangemPaySelectPlanSource.TIERS_ONBOARDING,
|
||||
),
|
||||
)
|
||||
else -> uiState.update { stateFactory.getLoadingState() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ import arrow.core.right
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.model.MutableParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.domain.models.StatusSource
|
||||
import com.tangem.domain.models.account.AccountStatus
|
||||
import com.tangem.domain.models.account.PaymentAccountStatusValue
|
||||
import com.tangem.domain.models.account.TangemPayCustomerTariffPlan
|
||||
import com.tangem.domain.models.account.VirtualAccountOnramp
|
||||
import com.tangem.domain.models.pay.TangemPayCardFrozenState
|
||||
import com.tangem.domain.models.pay.TangemPayDetailsInitialRoute
|
||||
|
|
@ -18,6 +20,8 @@ import com.tangem.domain.visa.model.TangemPayTxHistoryItem
|
|||
import com.tangem.features.tangempay.addFundsButton
|
||||
import com.tangem.features.tangempay.components.TangemPayDetailsContainerComponent
|
||||
import com.tangem.features.tangempay.entity.TangemPayDetailsBalanceBlockState
|
||||
import com.tangem.features.tangempay.navigation.TangemPayAccountDetailsInnerRoute
|
||||
import com.tangem.features.tangempay.tiers.select.TangemPaySelectPlanSource
|
||||
import com.tangem.features.tangempay.tangemPayCard
|
||||
import com.tangem.features.tangempay.withdrawButton
|
||||
import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider
|
||||
|
|
@ -44,6 +48,7 @@ internal class TangemPayDetailsModelTest {
|
|||
private val paymentAccountStatusSupplier: PaymentAccountStatusSupplier = mockk()
|
||||
private val cardDetailsRepository: TangemPayCardDetailsRepository = mockk(relaxed = true)
|
||||
private val analytics: AnalyticsEventHandler = mockk(relaxed = true)
|
||||
private val router: Router = mockk(relaxed = true)
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideMutedCases")
|
||||
|
|
@ -114,6 +119,33 @@ internal class TangemPayDetailsModelTest {
|
|||
model.onDestroy()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN awaiting plan selection WHEN model created THEN inner stack is replaced with plan selection`() =
|
||||
runTest {
|
||||
// GIVEN
|
||||
val tariffPlan: TangemPayCustomerTariffPlan = mockk(relaxed = true)
|
||||
val awaitingPlanSelection = PaymentAccountStatusValue.AwaitingPlanSelection(
|
||||
source = StatusSource.ACTUAL,
|
||||
tariffPlan = tariffPlan,
|
||||
)
|
||||
|
||||
// WHEN
|
||||
val model = createModel(testScope = this, statusValue = awaitingPlanSelection)
|
||||
advanceUntilIdle()
|
||||
|
||||
// THEN
|
||||
verify(exactly = 1) {
|
||||
router.replaceAll(
|
||||
TangemPayAccountDetailsInnerRoute.SelectPlan(
|
||||
tariffPlan = tariffPlan,
|
||||
source = TangemPaySelectPlanSource.TIERS_ONBOARDING,
|
||||
),
|
||||
)
|
||||
}
|
||||
verify(exactly = 0) { router.push(any(), any()) }
|
||||
model.onDestroy()
|
||||
}
|
||||
|
||||
private fun createModel(
|
||||
testScope: TestScope,
|
||||
statusSource: StatusSource = StatusSource.ACTUAL,
|
||||
|
|
@ -164,7 +196,7 @@ internal class TangemPayDetailsModelTest {
|
|||
paymentAccountStatusSupplier = paymentAccountStatusSupplier,
|
||||
dispatchers = testScope.createTestingCoroutineDispatcherProvider(),
|
||||
analytics = analytics,
|
||||
router = mockk(relaxed = true),
|
||||
router = router,
|
||||
urlOpener = mockk(relaxed = true),
|
||||
cardDetailsRepository = cardDetailsRepository,
|
||||
getBalanceHidingSettingsUseCase = mockk(relaxed = true),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue