Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-17 12:59:21 +04:00
parent aa11b11fee
commit 1e8890dac4
3 changed files with 45 additions and 2 deletions

View file

@ -29,6 +29,9 @@ class YieldSupplyGetRewardsBalanceUseCase(
val fiatRate = status.value.fiatRate
if (cryptoAmount?.compareTo(BigDecimal.ZERO) == 0) {
emit(
YieldSupplyRewardBalance(fiatBalance = null, cryptoBalance = null),
)
return@flow
}

View file

@ -49,6 +49,38 @@ class YieldSupplyGetRewardsBalanceUseCaseTest {
assertThat(emissions).isEmpty()
}
@Test
fun `GIVEN zero amount WHEN invoke THEN emit null balances`() = runTest {
val network = createNetwork()
val token = createToken(network)
val status = CryptoCurrencyStatus(
currency = token,
value = CryptoCurrencyStatus.Custom(
amount = BigDecimal.ZERO,
fiatAmount = null,
fiatRate = BigDecimal.ONE,
priceChange = null,
yieldBalance = null,
yieldSupplyStatus = null,
hasCurrentNetworkTransactions = false,
pendingTransactions = emptySet(),
networkAddress = NetworkAddress.Single(
NetworkAddress.Address(value = "0xabc", type = NetworkAddress.Address.Type.Primary),
),
sources = CryptoCurrencyStatus.Sources(),
),
)
val dispatcherProvider = testDispatcherProvider(this)
val useCase = YieldSupplyGetRewardsBalanceUseCase(repository, dispatcherProvider)
val appCurrency = AppCurrency.Default
val emissions = useCase(status, appCurrency).toList()
assertThat(emissions).hasSize(1)
assertThat(emissions[0].fiatBalance).isNull()
assertThat(emissions[0].cryptoBalance).isNull()
}
@Test
fun `GIVEN coin currency WHEN invoke THEN emit nothing`() = runTest {
val network = createNetwork()