diff options
Diffstat (limited to 'android/app/src/test')
| -rw-r--r-- | android/app/src/test/java/org/terst/doot/widget/ui/DootWidgetGridTest.kt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/android/app/src/test/java/org/terst/doot/widget/ui/DootWidgetGridTest.kt b/android/app/src/test/java/org/terst/doot/widget/ui/DootWidgetGridTest.kt new file mode 100644 index 0000000..b3d8384 --- /dev/null +++ b/android/app/src/test/java/org/terst/doot/widget/ui/DootWidgetGridTest.kt @@ -0,0 +1,34 @@ +package org.terst.doot.widget.ui + +import org.junit.Assert.assertEquals +import org.junit.Test +import org.terst.doot.widget.data.WidgetItem + +class DootWidgetGridTest { + + private fun tomorrowEvent(startIso: String, endIso: String): WidgetItem = WidgetItem( + id = "tmrw", title = "Tomorrow Event", source = "calendar", type = "event", + start = startIso, end = endIso + ) + + @Test + fun `calcGridStart on an unfiltered mixed list is skewed by tomorrow's event hour`() { + // Documents why WidgetRoot MUST pre-filter to today-only events before calling + // this function: it has no date awareness, only hour-of-day. "now" is 22:00 + // today (2026-07-12); the only item is tomorrow's (2026-07-13) 10:00 event. + val mixedList = listOf(tomorrowEvent("2026-07-13T10:00:00Z", "2026-07-13T14:30:00Z")) + assertEquals(9, calcGridStart(mixedList, nowHour = 22)) + } + + @Test + fun `calcGridStart on the correctly today-filtered (empty) list falls back to nowHour`() { + val gridStart = calcGridStart(emptyList(), nowHour = 22) + assertEquals(21, gridStart) + } + + @Test + fun `calcGridEnd falls back to nowHour plus eight when no today events, capped at 23`() { + val gridEnd = calcGridEnd(emptyList(), nowHour = 22) + assertEquals(23, gridEnd) + } +} |
