Set the month chip time apart from its title (#219)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package de.jeanlucmakiola.calendula.ui.month
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import de.jeanlucmakiola.calendula.domain.EventInstance
|
||||
import kotlinx.datetime.DateTimeUnit
|
||||
@@ -55,6 +57,26 @@ class MonthChipTimeTest {
|
||||
assertThat(time).isEqualTo("2:30 pm")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the time is set apart from the title it precedes`() {
|
||||
val label = monthChipLabel("09:05", "Standup", Color.Black)
|
||||
assertThat(label.text).isEqualTo("09:05 Standup")
|
||||
// Only the time is restyled: the title keeps labelSmall as the theme
|
||||
// sets it, so the two read as separate things on one line (#219).
|
||||
val spans = label.spanStyles
|
||||
assertThat(spans).hasSize(1)
|
||||
assertThat(spans.single().start).isEqualTo(0)
|
||||
assertThat(spans.single().end).isEqualTo("09:05".length)
|
||||
assertThat(spans.single().item.fontWeight).isEqualTo(FontWeight.Normal)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a chip without a time is styled title and nothing else`() {
|
||||
val label = monthChipLabel(null, "Standup", Color.Black)
|
||||
assertThat(label.text).isEqualTo("Standup")
|
||||
assertThat(label.spanStyles).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `an all-day chip never shows a time`() {
|
||||
val time = monthChipTime(allDay(), continuesLeft = false, zone, is24Hour = true, locale)
|
||||
|
||||
Reference in New Issue
Block a user