Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-01 13:59:11 +03:00
parent 5b1663edc7
commit 03bef8f61f
2 changed files with 41 additions and 46 deletions

View file

@ -440,5 +440,42 @@ internal class DefaultQuotesFetcherTest {
}
}
@Test
fun `fetch successfully if not all quotes are fetched`() = runTest {
// Arrange
val apiQuote = MockQuoteResponseFactory.createSinglePrice(BigDecimal.ONE)
val apiResponse = ApiResponse.Success(
data = QuotesResponse(quotes = mapOf("ethereum" to apiQuote)),
)
coEvery {
tangemTechApi.getQuotes(currencyId = "usd", coinIds = "ethereum,bitcoin", fields = "price")
} returns apiResponse
// Act
val actual = fetcher.fetch(
fiatCurrencyId = "usd",
currenciesIds = setOf("ethereum", "bitcoin"),
fields = setOf(Field.PRICE),
)
// Assert
val expected = QuotesResponse(
quotes = mapOf(
"ethereum" to apiQuote,
"bitcoin" to QuotesResponse.Quote.EMPTY,
),
).right()
Truth.assertThat(actual).isEqualTo(expected)
coVerify(exactly = 1) {
tangemTechApi.getQuotes(
currencyId = "usd",
coinIds = "ethereum,bitcoin",
fields = "price",
)
}
}
private fun Iterable<QuoteMetadata>?.toResponseQuotes() = this!!.associate { it.cryptoCurrencyId to it.value }
}