feat(format-common-impl): add a regression test for flow emission
This commit is contained in:
parent
b84f7ccd07
commit
39a0284cd5
1 changed files with 13 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package app.passwordstore.data.passfile
|
package app.passwordstore.data.passfile
|
||||||
|
|
||||||
|
import app.cash.turbine.Event
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import app.passwordstore.test.CoroutineTestRule
|
import app.passwordstore.test.CoroutineTestRule
|
||||||
import app.passwordstore.util.time.TestUserClock
|
import app.passwordstore.util.time.TestUserClock
|
||||||
|
@ -19,6 +20,7 @@ import kotlin.test.assertTrue
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import kotlin.time.ExperimentalTime
|
import kotlin.time.ExperimentalTime
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.runner.RunWith
|
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<Totp> } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onlyLooksForUriInFirstLine() {
|
fun onlyLooksForUriInFirstLine() {
|
||||||
val entry = makeEntry("id:\n$TOTP_URI")
|
val entry = makeEntry("id:\n$TOTP_URI")
|
||||||
|
|
Loading…
Reference in a new issue