Lukasz Kalnik
11/11/2025, 1:52 PMInstancePerLeaf as an extension/listener. Do you have any hints how I could go about it? More details in 🧵Lukasz Kalnik
11/11/2025, 1:53 PMLukasz Kalnik
11/11/2025, 1:54 PMLukasz Kalnik
11/11/2025, 1:56 PMLukasz Kalnik
11/11/2025, 1:58 PMLukasz Kalnik
11/11/2025, 1:58 PM"given a viewmodel was created" - {
val viewModel = MyViewModel()
viewModel.uiState shouldBe EmptyState
"when the customer scanned the wrong code then show error dialog" - {
viewModel.scanCode(wrongCode)
viewModel.uiState shouldBe ErrorDialog
"when the customer dismissed the dialog then close it" {
viewModel.onDismissErrorDialog()
viewModel.uiState shouldBe EmptyState
}
"when customer selected manual input then show manual input dialog" - {
viewModel.onManualInputSelected()
viewModel.uiState shouldBe ManualInput
"when the customer entered correct code manually then show success" {
viewModel.enterCode(correctCode)
viewModel.uiState shouldBe Success
}
}
}
"when the customer scanned the correct code then show success" {
viewModel.scanCode(correctCode)
viewModel.uiState shouldBe Success
}
}Lukasz Kalnik
11/11/2025, 2:00 PMscanCode() in Success state should not be allowed.Lukasz Kalnik
11/11/2025, 2:01 PMonManualInputSelected() should also only be allowed in ErrorDialog state, not in EmptyState.Lukasz Kalnik
11/11/2025, 2:02 PMLukasz Kalnik
11/11/2025, 2:47 PMLukasz Kalnik
11/11/2025, 3:15 PMclass MyTest : FreeSpec({
"a" - {
sut.doSomething()
"b" - {
sut.doSomethingElse()
"c" {
sut.doSomethingMore()
}
"d" {
sut.doSomething()
}
}
"e" {
sut.doSomethingElseYet()
}
}
})
I need to inject sut in state from the end of "a" to "b" and "e".
I need to inject sut in the state from the end of "b" to "c" and "d".Lukasz Kalnik
11/11/2025, 3:18 PMsut instances.
And I need to know which test node's child the current test is (what its container is).Lukasz Kalnik
11/11/2025, 3:21 PM"c" and "d" or "b" and "e").Lukasz Kalnik
11/11/2025, 3:23 PMLukasz Kalnik
11/11/2025, 3:24 PMLukasz Kalnik
11/11/2025, 3:42 PMsut somehow in the test body.