Skip to content

Instantly share code, notes, and snippets.

@waterlink
Created February 9, 2019 12:55
Show Gist options
  • Save waterlink/e26a4dc585b628d6eb6074b9383a209f to your computer and use it in GitHub Desktop.
Save waterlink/e26a4dc585b628d6eb6074b9383a209f to your computer and use it in GitHub Desktop.
describe("FetcherTwo") {
lateinit var asyncQueue: AsyncQueue
lateinit var fetcher: FetcherTwo
val client = Client()
beforeEachTest {
asyncQueue = AsyncQueue()
fetcher = FetcherTwo(asyncQueue, client)
}
it("perform - calls client to do other stuff") {
client.mockResponseStatus("successful")
fetcher.perform()
assertThat(client.actions).contains("doSomeOtherStuff")
}
it("perform - does not trigger async polling") {
client.mockResponseStatus("successful")
fetcher.perform()
assertThat(asyncQueue).isEmpty()
}
it("perform - triggers async polling job when accepted") {
client.mockResponseStatus("accepted")
fetcher.perform()
assertThat(asyncQueue).contains(fetcher::checkLastOperation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment