diff --git a/android/app/src/test/java/tv/orbit/classic/EventAppointmentsTest.kt b/android/app/src/test/java/tv/orbit/classic/EventAppointmentsTest.kt index f6b0a72..9c6dc11 100644 --- a/android/app/src/test/java/tv/orbit/classic/EventAppointmentsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/EventAppointmentsTest.kt @@ -44,4 +44,20 @@ class EventAppointmentsTest { assertEquals(3, starts.size) assertTrue("late by $starts", starts.all { it in 0..20 }) } + + @Test fun eligibilityIsWorkedOutAfreshWhenThePoolOrTheBlockChanges() { + fun show(t: String) = PoolSeries(t, t, listOf(PoolEpisode("$t-1", "s", EpisodeMark(1, 1), "E1", 1_800_000))) + val part = DayPart(0, 24, listOf("A", "B")) + val first = listOf(show("A"), show("C")) + assertEquals(listOf("A"), dayPartFor(first, listOf(part), monday, zone).first.map { it.title }) + // A refreshed pool is a new list, even with a show added from the catalogue: it's matched again. + val refreshed = listOf(show("A"), show("B"), show("C")) + assertEquals(listOf("A", "B"), dayPartFor(refreshed, listOf(part), monday, zone).first.map { it.title }) + // A changed block (a new release's rules) is a new block: it's matched again too. + val widened = part.copy(titles = part.titles + "C") + assertEquals(listOf("A", "B", "C"), dayPartFor(refreshed, listOf(widened), monday, zone).first.map { it.title }) + // And the first pool still gives its own answer. + assertEquals(listOf("A"), dayPartFor(first, listOf(part), monday, zone).first.map { it.title }) + } + }