Jon Bailey
11/01/2023, 5:47 PMdata 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).test(this) {
expectInitialState()
containerHost.doSomethingUseful()
expectState { copy("foo") }
}
}
If I change ExampleContainerHost(this).test(this) {
to ExampleContainerHost(GlobalScope).test(this) {
Then the test passes as expected. So I guess my question is what CoroutineScope is the container meant to be created with in a test? The new test docs just use ViewModels to create the ContainerHost.