Skip to content

Commit

Permalink
Update details screen test with number shortening logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shorthouse committed Apr 2, 2024
1 parent df9867d commit c9f30fb
Showing 1 changed file with 93 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ class DetailsScreenTest {
onNodeWithText("Market Cap Rank").assertIsDisplayed()
onNodeWithText("2").assertIsDisplayed()
onNodeWithText("Market Cap").assertIsDisplayed()
onNodeWithText("$225,722,901,094.00").assertIsDisplayed()
onNodeWithText("$225.72B").assertIsDisplayed()
onNodeWithText("Volume (24h)").assertIsDisplayed()
onNodeWithText("$6,627,669,115.00").assertIsDisplayed()
onNodeWithText("$6.63B").assertIsDisplayed()
onNodeWithText("Circulating Supply").assertIsDisplayed()
onNodeWithText("120,186,525").assertIsDisplayed()
onNodeWithText("All Time High").assertIsDisplayed()
Expand Down Expand Up @@ -518,9 +518,9 @@ class DetailsScreenTest {
onNodeWithText("Market Cap Rank").assertIsDisplayed()
onNodeWithText("2").assertIsDisplayed()
onNodeWithText("Market Cap").assertIsDisplayed()
onNodeWithText("£225,722,901,094.00").assertIsDisplayed()
onNodeWithText("£225.72B").assertIsDisplayed()
onNodeWithText("Volume (24h)").assertIsDisplayed()
onNodeWithText("$6,627,669,115.00").assertIsDisplayed()
onNodeWithText("$6.63B").assertIsDisplayed()
onNodeWithText("Circulating Supply").assertIsDisplayed()
onNodeWithText("120,186,525").assertIsDisplayed()
onNodeWithText("All Time High ($)").assertIsDisplayed()
Expand All @@ -531,4 +531,93 @@ class DetailsScreenTest {
onNodeWithText("7 Aug 2015").assertIsDisplayed()
}
}

@Test
fun when_pricesAreLarge_should_showShortenedPrices() {
val uiStateSuccess = DetailsUiState.Success(
CoinDetails(
id = "ethereum",
name = "Ethereum",
symbol = "ETH",
imageUrl = "https://cdn.coinranking.com/rk4RKHOuW/eth.svg",
currentPrice = Price("1879.14"),
marketCap = Price("49491394.23440234"),
marketCapRank = "2",
volume24h = Price("1009900243"),
circulatingSupply = "120,186,525",
allTimeHigh = Price("3084938574102"),
allTimeHighDate = "10 Nov 2021",
listedDate = "7 Aug 2015"
),
CoinChart(
prices = persistentListOf(
BigDecimal("1755.19"),
BigDecimal("1749.71"),
BigDecimal("1750.94"),
BigDecimal("1748.44"),
BigDecimal("1743.98"),
BigDecimal("1740.25")
),
minPrice = Price("1632.46"),
maxPrice = Price("1922.83"),
periodPriceChangePercentage = Percentage("7.06")
),
chartPeriod = ChartPeriod.Day,
isCoinFavourite = true
)

composeTestRule.setContent {
AppTheme {
DetailsScreen(
uiState = uiStateSuccess,
onNavigateUp = {},
onClickFavouriteCoin = {},
onClickChartPeriod = {}
)
}
}

composeTestRule.apply {
onNodeWithContentDescription("Back").assertIsDisplayed()
onNodeWithContentDescription("Favourite").assertIsDisplayed()

onNodeWithText("Ethereum").assertIsDisplayed()
onNodeWithText("ETH").assertIsDisplayed()
onNodeWithText("$1,879.14").assertIsDisplayed()
onNodeWithText("+7.06%").assertIsDisplayed()
onNodeWithText("Past day").assertIsDisplayed()

onNodeWithText("1H").assertIsDisplayed()
onNodeWithText("1D").assertIsDisplayed()
onNodeWithText("1W").assertIsDisplayed()
onNodeWithText("1M").assertIsDisplayed()
onNodeWithText("3M").assertIsDisplayed()
onNodeWithText("1Y").assertIsDisplayed()
onNodeWithText("5Y").assertIsDisplayed()

onNodeWithText("Chart Range").assertIsDisplayed()
onNodeWithText("Low").assertIsDisplayed()
onNodeWithText("$1,632.46").assertIsDisplayed()
onNodeWithText("High").assertIsDisplayed()
onNodeWithText("$1,922.83").assertIsDisplayed()

onNodeWithText("7 Aug 2015").performScrollTo()

onNodeWithText("Market Stats").assertIsDisplayed()
onNodeWithText("Market Cap Rank").assertIsDisplayed()
onNodeWithText("2").assertIsDisplayed()
onNodeWithText("Market Cap").assertIsDisplayed()
onNodeWithText("$49.49M").assertIsDisplayed()
onNodeWithText("Volume (24h)").assertIsDisplayed()
onNodeWithText("$1.01B").assertIsDisplayed()
onNodeWithText("Circulating Supply").assertIsDisplayed()
onNodeWithText("120,186,525").assertIsDisplayed()
onNodeWithText("All Time High").assertIsDisplayed()
onNodeWithText("$3.08T").assertIsDisplayed()
onNodeWithText("All Time High Date").assertIsDisplayed()
onNodeWithText("10 Nov 2021").assertIsDisplayed()
onNodeWithText("Listed Date").assertIsDisplayed()
onNodeWithText("7 Aug 2015").assertIsDisplayed()
}
}
}

0 comments on commit c9f30fb

Please sign in to comment.