add browser-example-with-library maven project (kotlin->javascript)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
package sample
|
||||
|
||||
import kotlin.Pair
|
||||
import kotlin.browser.document
|
||||
import library.sample.*
|
||||
|
||||
fun myApp() {
|
||||
val element = document.getElementById("foo")
|
||||
if (element != null) {
|
||||
val p = Pair(10, 20)
|
||||
val x = pairAdd(p)
|
||||
val y = pairMul(p)
|
||||
val z = IntHolder(100).value
|
||||
element.appendChild(document.createTextNode("x=$x y=$y z=$z")!!)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package test.sample
|
||||
|
||||
import org.junit.Test as test
|
||||
import org.openqa.selenium.WebDriver
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver
|
||||
import org.openqa.selenium.By
|
||||
import java.io.File
|
||||
import kotlin.test.*
|
||||
|
||||
open class SampleTest {
|
||||
open val driver: WebDriver = HtmlUnitDriver(true)
|
||||
|
||||
test fun homePage(): Unit {
|
||||
driver.get("file://" + File("sample.html").getCanonicalPath())
|
||||
Thread.sleep(1000)
|
||||
|
||||
val foo = driver.findElement(By.id("foo"))!!
|
||||
val text = foo.getText() ?: ""
|
||||
println("Found $foo with text '$text'")
|
||||
assertEquals("x=30 y=200 z=100", text.trim())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user