Brendan Campbell-hartzell
08/13/2021, 4:54 AMfun `should enable inputs`() {
val job by lazy {
CoroutineScope(Dispatchers.Default).launch {
error("Intended async error")
}
}
behavior = { job }
interact {
view.nameInput.text = "Banana"
view.timeInput.valueFactory.value = 0L
view.submitButton.fire()
}
runBlocking {
job.join()
}
assertThat(view.nameInput).isEnabled
assertThat(view.timeInput).isEnabled
}
private fun submit() {
nameInput.isDisable = true
timeInput.isDisable = true
val nonBlankName = NonBlankString.create(nameInput.text) ?: return
CoroutineScope(Dispatchers.JavaFx).launch {
try {
createStoryEventController.createStoryEvent(nonBlankName).join()
} catch (t: Throwable) {
}
nameInput.isDisable = false
timeInput.isDisable = false
}/*
createStoryEventController.createStoryEvent(nonBlankName).invokeOnCompletion { potentialFailure ->
runBlocking {
nameInput.isDisable = false
timeInput.isDisable = false
}
}*/
}
Job
and the behavior
property in the tests is what's being called/returned by the mocked createStoryEventControllerCoroutineExceptionHandler
. For anyone else curious, here's where I found it:
https://kotlinlang.org/docs/exception-handling.html#cancellation-and-exceptions