hey so, for testing UI handlers that leverage `sus...
# coroutines
g
hey so, for testing UI handlers that leverage `suspend fun`'s, whats your guys strategy? eg
Copy code
class someController(fileSystem: FancyAsyncFileSystem) {
  override fun initialize() = suspending {
    //things that call other suspend funs and async methods
  }

  @FXML fun handleWhateverAction(userAction: Event) = suspending {

    val fileContent = await(fileSystem.loadFileAsync(Paths.get(textField.text)))
    //things that call other suspend...

    filePreviewArea.text = fileContent
  }
}
and its test
Copy code
class WhateverControllerTests {
  @Test fun `when clicking on the whatever whatever should whatever the whatevers`(){
    //setup
    val fs = FakeFancyFileSystem().apply { setContent("a/b/c", "testing!") }
    val controller = WhateverController(fs).apply {
      textField.text = "a/b/c"
    } 

    //act
    controller.handleWhateverAction(NonDescriptEvent)

    //problem: async computation started and because of the enforced `void`-ness of the java handlers, any reference to a Future object or something I can synchronize with is gone
    //assert
     assertThat(controller.filePreviewTextArea.text).isEqualTo("testing!")
  }
}