Updated on 2026-08-14
This commit is contained in:
parent
67577e8653
commit
b5209c613d
5 changed files with 108 additions and 21 deletions
|
|
@ -7,11 +7,14 @@ import com.tangem.domain.models.wallet.UserWalletId
|
|||
import com.tangem.domain.yield.supply.models.YieldBoostPromo
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostStatus
|
||||
import com.tangem.domain.yield.supply.promo.YieldPromoRepository
|
||||
import io.mockk.Deregisterable
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.mockk
|
||||
import io.mockk.registerInstanceFactory
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.datetime.Instant
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
|
@ -25,11 +28,23 @@ class IsYieldBoostPromoEnabledForTokenUseCaseTest {
|
|||
private val contractAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||
private val networkRawId = "ethereum"
|
||||
|
||||
// Stub concrete instances of the sealed return types so MockK doesn't subclass them while recording coEvery
|
||||
// (Objenesis on a JVM-sealed type throws InstantiationError flakily under full-suite CI runs).
|
||||
private val instanceFactories = mutableListOf<Deregisterable>()
|
||||
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
instanceFactories += registerInstanceFactory { YieldBoostPromo.None }
|
||||
instanceFactories += registerInstanceFactory { YieldBoostStatus.NotStarted }
|
||||
useCase = IsYieldBoostPromoEnabledForTokenUseCase(repository = repository)
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
instanceFactories.forEach { it.deregister() }
|
||||
instanceFactories.clear()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN currency is coin WHEN invoke THEN returns Right(false)`() = runTest {
|
||||
val coin = createCoin()
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@ import com.tangem.domain.models.wallet.UserWalletId
|
|||
import com.tangem.domain.yield.supply.models.YieldBoostPromo
|
||||
import com.tangem.domain.yield.supply.models.YieldBoostStatus
|
||||
import com.tangem.domain.yield.supply.promo.YieldPromoRepository
|
||||
import io.mockk.Deregisterable
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.mockk
|
||||
import io.mockk.registerInstanceFactory
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.datetime.Instant
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
|
@ -23,11 +26,23 @@ class ShouldShowYieldBoostMainBannerUseCaseTest {
|
|||
private val contractAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||
private val networkRawId = "ethereum"
|
||||
|
||||
// Stub concrete instances of the sealed return types so MockK doesn't subclass them while recording coEvery
|
||||
// (Objenesis on a JVM-sealed type throws InstantiationError flakily under full-suite CI runs).
|
||||
private val instanceFactories = mutableListOf<Deregisterable>()
|
||||
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
instanceFactories += registerInstanceFactory { YieldBoostPromo.None }
|
||||
instanceFactories += registerInstanceFactory { YieldBoostStatus.NotStarted }
|
||||
useCase = ShouldShowYieldBoostMainBannerUseCase(repository = repository)
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
instanceFactories.forEach { it.deregister() }
|
||||
instanceFactories.clear()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN promo repository throws WHEN invoke THEN returns Left`() = runTest {
|
||||
coEvery { repository.getYieldBoostPromo(userWalletId, false) } throws RuntimeException("net")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue