Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created January 2, 2021 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/d6f148a451e4f030a21bfb3331db22fe to your computer and use it in GitHub Desktop.
Save le0nidas/d6f148a451e4f030a21bfb3331db22fe to your computer and use it in GitHub Desktop.
@Test fun `going back restores the previously visited URL`() {
val browser = Browser(FakeHistory())
browser.visit(URL("https://www.le0nidas.gr"))
browser.visit(URL("https://www.google.com"))
browser.back()
assertThat(browser.activeURL, equalTo(URL("https://www.le0nidas.gr")))
}
private class FakeHistory : History {
private val urls = mutableListOf<URL>()
override fun push(url: URL) {
urls.add(0, url)
}
override fun pop(): URL {
return urls.removeAt(0)
}
override fun peek(): URL {
return urls[0]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment