Brendan Campbell-hartzell
08/13/2021, 4:54 AMBrendan Campbell-hartzell
08/13/2021, 4:56 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
}
Brendan Campbell-hartzell
08/13/2021, 4:57 AMprivate 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
}
}*/
}
Brendan Campbell-hartzell
08/13/2021, 5:02 AMJob
and the behavior
property in the tests is what's being called/returned by the mocked createStoryEventControllerBrendan Campbell-hartzell
08/13/2021, 5:15 AMCoroutineExceptionHandler
. For anyone else curious, here's where I found it:
https://kotlinlang.org/docs/exception-handling.html#cancellation-and-exceptions