Skip to content

Commit

Permalink
Added distinct states test
Browse files Browse the repository at this point in the history
  • Loading branch information
floschu committed May 10, 2020
1 parent 1440c5e commit 9b9cc3a
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal class ImplementationTest {
}

@Test
fun `synchronous controller builder`() {
fun `synchronous controller`() {
val counterSut = testCoroutineScope.createSynchronousController<Int, Int>(
tag = "counter",
initialState = 0,
Expand All @@ -96,6 +96,19 @@ internal class ImplementationTest {
assertEquals(6, counterSut.currentState)
}

@Test
fun `only distinct states are emitted`() {
val sut = testCoroutineScope.createSynchronousController<Unit, Int>(
0,
reducer = { _, previousState -> previousState }
)
val testFlow = sut.state.testIn(testCoroutineScope)
sut.dispatch(Unit)
sut.dispatch(Unit)
sut.dispatch(Unit)
testFlow expect emissionCount(1) // no state changes
}

@Test
fun `collector receives latest and following states`() {
val sut = testCoroutineScope.counterController() // 0
Expand Down

0 comments on commit 9b9cc3a

Please sign in to comment.