Updated on 2026-08-14
This commit is contained in:
parent
06cb9620e9
commit
ad65a62b3f
2 changed files with 27 additions and 6 deletions
|
|
@ -142,13 +142,14 @@ internal class TangemPaySelectPlanModel @Inject constructor(
|
|||
modelScope.launch {
|
||||
submitTariffTransitionUseCase(params.userWalletId, transition).fold(
|
||||
ifRight = {
|
||||
when (params.source) {
|
||||
TangemPaySelectPlanSource.TIERS_ONBOARDING -> {
|
||||
when {
|
||||
transition.type == TangemPayTariffPlanTransition.Type.UPGRADE -> {
|
||||
router.replaceAll(TangemPayAccountDetailsInnerRoute.AccountDetails)
|
||||
}
|
||||
TangemPaySelectPlanSource.CHANGE_PLAN -> {
|
||||
router.pop()
|
||||
params.source == TangemPaySelectPlanSource.TIERS_ONBOARDING -> {
|
||||
router.replaceAll(TangemPayAccountDetailsInnerRoute.AccountDetails)
|
||||
}
|
||||
else -> router.pop()
|
||||
}
|
||||
},
|
||||
ifLeft = {
|
||||
|
|
|
|||
|
|
@ -258,7 +258,23 @@ internal class TangemPaySelectPlanModelTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN confirm AND submit succeeds WHEN onConfirmClick THEN router pops`() {
|
||||
fun `GIVEN change plan non-upgrade AND submit succeeds WHEN onConfirmClick THEN router pops`() {
|
||||
// GIVEN
|
||||
coEvery { submitTariffTransitionUseCase(USER_WALLET_ID, any()) } returns Unit.right()
|
||||
val model = createModel(source = TangemPaySelectPlanSource.CHANGE_PLAN)
|
||||
model.state.value.onPlanSelected(ACTIVATION_INDEX)
|
||||
selectContent(model).onSelectClick()
|
||||
|
||||
// WHEN
|
||||
confirmContent(model).onConfirmClick()
|
||||
|
||||
// THEN
|
||||
verify(exactly = 1) { router.pop() }
|
||||
verify(exactly = 0) { router.replaceAll(TangemPayAccountDetailsInnerRoute.AccountDetails) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN change plan upgrade AND submit succeeds WHEN onConfirmClick THEN replaces to account details`() {
|
||||
// GIVEN
|
||||
coEvery { submitTariffTransitionUseCase(USER_WALLET_ID, any()) } returns Unit.right()
|
||||
val model = createModel(source = TangemPaySelectPlanSource.CHANGE_PLAN)
|
||||
|
|
@ -268,7 +284,9 @@ internal class TangemPaySelectPlanModelTest {
|
|||
confirmContent(model).onConfirmClick()
|
||||
|
||||
// THEN
|
||||
verify(exactly = 1) { router.pop() }
|
||||
coVerify(exactly = 1) { submitTariffTransitionUseCase(USER_WALLET_ID, UPGRADE_TRANSITION) }
|
||||
verify(exactly = 1) { router.replaceAll(TangemPayAccountDetailsInnerRoute.AccountDetails) }
|
||||
verify(exactly = 0) { router.pop() }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -309,6 +327,8 @@ internal class TangemPaySelectPlanModelTest {
|
|||
private companion object {
|
||||
val USER_WALLET_ID = UserWalletId("aabbcc112233")
|
||||
|
||||
const val ACTIVATION_INDEX = 2
|
||||
|
||||
val UPGRADE_TRANSITION = transition(TangemPayTariffPlanTransition.Type.UPGRADE, "PLUS", isBasic = false)
|
||||
val DOWNGRADE_TRANSITION = transition(TangemPayTariffPlanTransition.Type.DOWNGRADE, "BASIC", isBasic = true)
|
||||
val ACTIVATION_TRANSITION = transition(TangemPayTariffPlanTransition.Type.ACTIVATION, "PLUS", isBasic = false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue