Mikolaj Leszczynski
11/06/2023, 2:32 PMscope
to create the container and to run the test. This will create a deadlock. The solution here is to use backgroundScope
. Here is a rewritten version that should work (not tested):
data class ExampleState(val value: String = "")
class ExampleContainerHost(scope: CoroutineScope):
ContainerHost<ExampleState, Unit> {
// create a container
override val container = scope.container<ExampleState, Unit>(ExampleState())
fun doSomethingUseful() = intent {
reduce { ExampleState("foo") }
}
}
@Test
fun exampleTest() = runTest {
ExampleContainerHost(this.backgroundScope).test(this) { // < --- Pass backgroundScope to orbit factory f-n
expectInitialState()
containerHost.doSomethingUseful()
expectState { copy("foo") }
}
}
I guess this is mostly a missing documentation issue 🙂 I'll try to fix this soon