diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-12-19 15:33:08 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2022-12-19 15:33:08 +0530 |
commit | 39a0284cd55298eb4930db681e813260aea58867 (patch) | |
tree | 4d46e5ae15a4b23ac150dd009c4cf748f4895e68 | |
parent | b84f7ccd078489e5fe38d16b28fa4d309c8ffa2f (diff) |
feat(format-common-impl): add a regression test for flow emission
-rw-r--r-- | format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt index 1fa50188..0d77cfe2 100644 --- a/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt +++ b/format-common-impl/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt @@ -5,6 +5,7 @@ package app.passwordstore.data.passfile +import app.cash.turbine.Event import app.cash.turbine.test import app.passwordstore.test.CoroutineTestRule import app.passwordstore.util.time.TestUserClock @@ -19,6 +20,7 @@ import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds import kotlin.time.ExperimentalTime import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.runner.RunWith @@ -178,6 +180,17 @@ class PasswordEntryTest { } @Test + fun emitsTotpEverySecond() = runTest { + val entry = makeEntry(TOTP_URI) + entry.totp.test { + delay(3000L) + val events = cancelAndConsumeRemainingEvents() + assertEquals(3, events.size) + assertTrue { events.all { event -> event is Event.Item<Totp> } } + } + } + + @Test fun onlyLooksForUriInFirstLine() { val entry = makeEntry("id:\n$TOTP_URI") assertNotNull(entry.password) |