Skip to content

Commit 0f6b8ca

Browse files
committed
Refactor to move weird functions out
1 parent 37693ac commit 0f6b8ca

2 files changed

Lines changed: 189 additions & 127 deletions

File tree

app/src/androidTest/java/dev/shorthouse/coinwatch/ui/component/PriceGraphTest.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dev.shorthouse.coinwatch.ui.component
22

33
import androidx.compose.foundation.layout.fillMaxWidth
44
import androidx.compose.foundation.layout.height
5+
import androidx.compose.foundation.layout.width
56
import androidx.compose.runtime.getValue
67
import androidx.compose.runtime.mutableStateOf
78
import androidx.compose.runtime.setValue
@@ -346,6 +347,46 @@ class PriceGraphTest {
346347
.assertCountEquals(0)
347348
}
348349

350+
@Test
351+
fun when_scrubDateLabelIsLongAndGraphIsNarrow_should_renderWithoutLayoutFailure() {
352+
val priceHistory = persistentListOf(
353+
PriceEntry(
354+
price = BigDecimal("100.00"),
355+
timestamp = 1L,
356+
formattedDate = "Yesterday 23:13"
357+
),
358+
PriceEntry(
359+
price = BigDecimal("110.00"),
360+
timestamp = 2L,
361+
formattedDate = "Yesterday 23:14"
362+
)
363+
)
364+
365+
composeTestRule.setContent {
366+
AppTheme {
367+
ScrubPriceGraph(
368+
priceHistory = priceHistory,
369+
priceChangePercentage = Percentage("10.00"),
370+
isGraphAnimated = false,
371+
onScrub = {},
372+
modifier = Modifier
373+
.width(40.dp)
374+
.height(180.dp)
375+
)
376+
}
377+
}
378+
379+
composeTestRule.onNodeWithTag(SCRUB_CANVAS_TAG, useUnmergedTree = true)
380+
.performTouchInput {
381+
down(Offset(x = width / 2f, y = height / 2f))
382+
}
383+
384+
composeTestRule.waitForIdle()
385+
386+
composeTestRule.onNodeWithTag(SCRUB_DATE_LABEL_TAG, useUnmergedTree = true)
387+
.assertIsDisplayed()
388+
}
389+
349390
private fun assertNodeHasDrawnPixels(tag: String) {
350391
val pixelMap = composeTestRule
351392
.onNodeWithTag(tag, useUnmergedTree = true)

0 commit comments

Comments
 (0)