Updated on 2026-08-14
This commit is contained in:
parent
503106376c
commit
2b943f239f
5 changed files with 22 additions and 28 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.promobanners.impl.campaigns.converters
|
||||
|
||||
import com.tangem.domain.promo.models.PromoCampaignId
|
||||
import com.tangem.features.promobanners.impl.campaigns.entity.CampaignType
|
||||
import com.tangem.utils.converter.Converter
|
||||
import javax.inject.Inject
|
||||
|
|
@ -9,14 +10,9 @@ internal class CampaignIdConverter @Inject constructor() :
|
|||
|
||||
override fun convert(value: String): CampaignType? {
|
||||
return when (value) {
|
||||
CAMPAIGN_ID_REACTIVATION -> CampaignType.ReactivationCashback(campaignId = value)
|
||||
CAMPAIGN_ID_WHALE -> CampaignType.WhaleSwapCashback(campaignId = value)
|
||||
PromoCampaignId.ReactivationCashback.slug -> CampaignType.ReactivationCashback(campaignId = value)
|
||||
PromoCampaignId.WhaleSwapCashback.slug -> CampaignType.WhaleSwapCashback(campaignId = value)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val CAMPAIGN_ID_WHALE = "1"
|
||||
const val CAMPAIGN_ID_REACTIVATION = "2"
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,14 @@ internal class CampaignIdConverterTest {
|
|||
}
|
||||
|
||||
private fun provideConvertModels() = listOf(
|
||||
ConvertModel(id = "1", expected = CampaignType.WhaleSwapCashback(campaignId = "1")),
|
||||
ConvertModel(id = "2", expected = CampaignType.ReactivationCashback(campaignId = "2")),
|
||||
ConvertModel(
|
||||
id = "whale-swap-cashback",
|
||||
expected = CampaignType.WhaleSwapCashback(campaignId = "whale-swap-cashback"),
|
||||
),
|
||||
ConvertModel(
|
||||
id = "reactivation-cashback",
|
||||
expected = CampaignType.ReactivationCashback(campaignId = "reactivation-cashback"),
|
||||
),
|
||||
ConvertModel(id = "0", expected = null),
|
||||
ConvertModel(id = "unknown", expected = null),
|
||||
ConvertModel(id = "", expected = null),
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ internal class CampaignsModelTest {
|
|||
private val messageSender: UiMessageSender = mockk(relaxed = true)
|
||||
private val analyticsEventHandler: AnalyticsEventHandler = mockk(relaxed = true)
|
||||
|
||||
// Real converter: "1" -> WhaleSwapCashback, "2" -> ReactivationCashback, else null.
|
||||
private val campaignIdConverter = CampaignIdConverter()
|
||||
|
||||
@BeforeEach
|
||||
|
|
@ -82,7 +81,9 @@ internal class CampaignsModelTest {
|
|||
// Arrange
|
||||
coEvery { getPromoCampaignStateUseCase.invoke(any(), any(), any()) } returns
|
||||
Either.Left(RuntimeException("network"))
|
||||
val model = createModel(campaignFlow = flowOf(CampaignRequest(campaignId = "1", userWalletId = userWalletId)))
|
||||
val model = createModel(
|
||||
campaignFlow = flowOf(CampaignRequest(campaignId = "whale-swap-cashback", userWalletId = userWalletId)),
|
||||
)
|
||||
|
||||
// Act
|
||||
advanceUntilIdle()
|
||||
|
|
@ -180,8 +181,8 @@ internal class CampaignsModelTest {
|
|||
}
|
||||
|
||||
private fun provideKnownCampaignModels() = listOf(
|
||||
KnownCampaignModel(campaignId = "1", expectedPromoId = PromoCampaignId.WhaleSwapCashback),
|
||||
KnownCampaignModel(campaignId = "2", expectedPromoId = PromoCampaignId.ReactivationCashback),
|
||||
KnownCampaignModel(campaignId = "whale-swap-cashback", expectedPromoId = PromoCampaignId.WhaleSwapCashback),
|
||||
KnownCampaignModel(campaignId = "reactivation-cashback", expectedPromoId = PromoCampaignId.ReactivationCashback),
|
||||
)
|
||||
|
||||
internal data class KnownCampaignModel(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue