From 39a0284cd55298eb4930db681e813260aea58867 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 19 Dec 2022 15:33:08 +0530 Subject: feat(format-common-impl): add a regression test for flow emission --- .../app/passwordstore/data/passfile/PasswordEntryTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 @@ -177,6 +179,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 } } + } + } + @Test fun onlyLooksForUriInFirstLine() { val entry = makeEntry("id:\n$TOTP_URI") -- cgit v1.2.3