From 54964f35d6873244cffd7971063e39695f586011 Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Mon, 19 Jul 2021 09:56:34 -0500 Subject: [PATCH] implemented and unit tested --- src/test/kotlin/kweb/HrefTest.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/test/kotlin/kweb/HrefTest.kt b/src/test/kotlin/kweb/HrefTest.kt index 678bed4701..e58068ddae 100644 --- a/src/test/kotlin/kweb/HrefTest.kt +++ b/src/test/kotlin/kweb/HrefTest.kt @@ -41,10 +41,13 @@ class HrefTest(@Arguments("--headless") private var driver: WebDriver) { fun testClick() { driver.get("http://localhost:7665/") val aElement = driver.findElement(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 } @@ -56,10 +59,14 @@ fun main() { class HrefTestApp { - internal val clicked: KVar = KVar(false) + lateinit var appUrl: KVar + + val renderCount = KVar(0) val server: Kweb = Kweb(port = 7665) { + appUrl = this.url doc.body { + renderCount.value++ route { path("/") { a().let { a ->