Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 39a0284

Browse files
committed
feat(format-common-impl): add a regression test for flow emission
1 parent b84f7cc commit 39a0284

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package app.passwordstore.data.passfile
77

8+
import app.cash.turbine.Event
89
import app.cash.turbine.test
910
import app.passwordstore.test.CoroutineTestRule
1011
import app.passwordstore.util.time.TestUserClock
@@ -19,6 +20,7 @@ import kotlin.test.assertTrue
1920
import kotlin.time.Duration.Companion.seconds
2021
import kotlin.time.ExperimentalTime
2122
import kotlinx.coroutines.ExperimentalCoroutinesApi
23+
import kotlinx.coroutines.delay
2224
import kotlinx.coroutines.test.runTest
2325
import org.junit.Rule
2426
import org.junit.runner.RunWith
@@ -177,6 +179,17 @@ class PasswordEntryTest {
177179
}
178180
}
179181

182+
@Test
183+
fun emitsTotpEverySecond() = runTest {
184+
val entry = makeEntry(TOTP_URI)
185+
entry.totp.test {
186+
delay(3000L)
187+
val events = cancelAndConsumeRemainingEvents()
188+
assertEquals(3, events.size)
189+
assertTrue { events.all { event -> event is Event.Item<Totp> } }
190+
}
191+
}
192+
180193
@Test
181194
fun onlyLooksForUriInFirstLine() {
182195
val entry = makeEntry("id:\n$TOTP_URI")

0 commit comments

Comments
 (0)