Some checks failed
Build TV app / build (push) Failing after 2s
The club shortcut now offers every club of the first three German divisions instead of two hard-coded ones. Up to three can be active at once; benjamin and tobiasb still start with Hansa and the VfB switched on. Also fixes a crash on the left jump out of the channel list: the jump targeted a FocusRequester bound to the selected rail row, and a row that is scrolled out of a LazyColumn is not composed, so requesting focus on it threw. Jumps are now attempted and fall back to normal focus movement. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
62 lines
2.1 KiB
Kotlin
62 lines
2.1 KiB
Kotlin
package dev.castarr.tv.data
|
|
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Assert.assertFalse
|
|
import org.junit.Assert.assertTrue
|
|
import org.junit.Test
|
|
|
|
class TeamFiltersTest {
|
|
|
|
private val hansa = TeamFilters.byKey("hansa")!!
|
|
private val vfb = TeamFilters.byKey("stuttgart")!!
|
|
|
|
@Test
|
|
fun `matches the club regardless of case and surrounding text`() {
|
|
assertTrue(hansa.matches("3. Liga: FC Hansa Rostock - Dynamo Dresden"))
|
|
assertTrue(hansa.matches("HANSA ROSTOCK KOMPAKT"))
|
|
assertTrue(vfb.matches("Bundesliga: VfB Stuttgart - Bayern München"))
|
|
}
|
|
|
|
@Test
|
|
fun `does not match unrelated programmes`() {
|
|
assertFalse(hansa.matches("Tagesschau"))
|
|
assertFalse(vfb.matches("Hansa Rostock - Saarbrücken"))
|
|
}
|
|
|
|
@Test
|
|
fun `scans sport and free-to-air groups`() {
|
|
listOf("DAZN Event", "Sky Sport", "Magenta Sport", "Amazon Prime", "Free TV / HD+", "DYN Sport")
|
|
.forEach { assertTrue(it, TeamFilters.scansGroup(it)) }
|
|
}
|
|
|
|
@Test
|
|
fun `skips NFL and unrelated groups`() {
|
|
assertFalse(TeamFilters.scansGroup("DAZN Event NFL"))
|
|
assertFalse(TeamFilters.scansGroup("Kids"))
|
|
assertFalse(TeamFilters.scansGroup("Musik"))
|
|
}
|
|
|
|
@Test
|
|
fun `assigns each viewer their own club by default`() {
|
|
assertEquals(listOf("hansa"), TeamFilters.defaultKeysFor("benjamin"))
|
|
assertEquals(listOf("stuttgart"), TeamFilters.defaultKeysFor("TobiasB"))
|
|
assertTrue(TeamFilters.defaultKeysFor("someone-else").isEmpty())
|
|
}
|
|
|
|
@Test
|
|
fun `club keys are unique and every club has needles`() {
|
|
val keys = TeamFilters.all.map { it.key }
|
|
assertEquals(keys.size, keys.toSet().size)
|
|
assertTrue(TeamFilters.all.all { it.needles.isNotEmpty() })
|
|
assertTrue(TeamFilters.all.all { c -> c.needles.all { it == it.lowercase() } })
|
|
}
|
|
|
|
@Test
|
|
fun `covers all three divisions`() {
|
|
assertTrue(TeamFilters.all.size > 50)
|
|
listOf("bayern", "schalke", "hansa").forEach {
|
|
assertTrue(it, TeamFilters.byKey(it) != null)
|
|
}
|
|
}
|
|
}
|