-
-
Save le0nidas/d6f148a451e4f030a21bfb3331db22fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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