test: cover terminal indexing progress ordering

This commit is contained in:
jay
2026-11-13 14:48:37 -05:00
parent 23419cc35e
commit 2f4b600a0a
@@ -45,4 +45,24 @@ class IndexingProgressCoalescerTest {
assertEquals(listOf(first, latest), emitted)
}
@Test
fun submit_indeterminate_flushesLatestSongsFirst() = runTest {
val emitted = mutableListOf<IndexingProgress>()
val coalescer =
IndexingProgressCoalescer(
intervalMs = 250,
clock = { 0L },
onProgress = { emitted.add(it) },
)
val first = IndexingProgress.Songs(loaded = 0, explored = 1)
val latest = IndexingProgress.Songs(loaded = 2, explored = 3)
coalescer.submit(first)
coalescer.submit(IndexingProgress.Songs(loaded = 1, explored = 2))
coalescer.submit(latest)
coalescer.submit(IndexingProgress.Indeterminate)
assertEquals(listOf(first, latest, IndexingProgress.Indeterminate), emitted)
}
}