Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
implemented and unit tested
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jul 19, 2021
1 parent 98dd674 commit 54964f3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/test/kotlin/kweb/HrefTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ class HrefTest(@Arguments("--headless") private var driver: WebDriver) {
fun testClick() {
driver.get("http://localhost:7665/")
val aElement = driver.findElement<WebElement>(By.tagName("a"))
hrefTestApp.clicked.value shouldBe false
hrefTestApp.appUrl.value shouldBe "/"
hrefTestApp.renderCount.value shouldBe 1
aElement.click()
Thread.sleep(100)
hrefTestApp.clicked.value shouldBe true
hrefTestApp.appUrl.value shouldBe "/two"
// Page shouldn't have been re-rendered for a relative link
hrefTestApp.renderCount.value shouldBe 1
}


Expand All @@ -56,10 +59,14 @@ fun main() {

class HrefTestApp {

internal val clicked: KVar<Boolean> = KVar(false)
lateinit var appUrl: KVar<String>

val renderCount = KVar(0)

val server: Kweb = Kweb(port = 7665) {
appUrl = this.url
doc.body {
renderCount.value++
route {
path("/") {
a().let { a ->
Expand Down

0 comments on commit 54964f3

Please sign in to comment.