test: cover terminal indexing progress ordering
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user