Improve coverage of TemplatePresenter
This commit is contained in:
parent
50c70d10c8
commit
2c19ee6f8e
1 changed files with 13 additions and 4 deletions
|
|
@ -21,7 +21,7 @@ package io.element.android.features.template
|
||||||
import app.cash.molecule.RecompositionClock
|
import app.cash.molecule.RecompositionClock
|
||||||
import app.cash.molecule.moleculeFlow
|
import app.cash.molecule.moleculeFlow
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth
|
import com.google.common.truth.Truth.assertThat
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -29,15 +29,24 @@ import org.junit.Test
|
||||||
class TemplatePresenterTests {
|
class TemplatePresenterTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - `() = runTest {
|
fun `present - initial state`() = runTest {
|
||||||
|
|
||||||
val presenter = TemplatePresenter()
|
val presenter = TemplatePresenter()
|
||||||
moleculeFlow(RecompositionClock.Immediate) {
|
moleculeFlow(RecompositionClock.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
Truth.assertThat(initialState)
|
assertThat(initialState)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - send event`() = runTest {
|
||||||
|
val presenter = TemplatePresenter()
|
||||||
|
moleculeFlow(RecompositionClock.Immediate) {
|
||||||
|
presenter.present()
|
||||||
|
}.test {
|
||||||
|
val initialState = awaitItem()
|
||||||
|
initialState.eventSink.invoke(TemplateEvents.MyEvent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue