diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-01-29 21:03:34 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-01-29 21:03:34 +0100 |
commit | 2c7ca3f8808935fc0c56458dca54f7bf417141f7 (patch) | |
tree | 68d02115d3cc0467f825560f2b65a9591e5d78bc /examples/showcase/src/test/kotlin | |
parent | b43764a2088912162ed5e8df2f6da7d2598fb1a3 (diff) | |
download | kvision-2c7ca3f8808935fc0c56458dca54f7bf417141f7.tar.gz kvision-2c7ca3f8808935fc0c56458dca54f7bf417141f7.tar.bz2 kvision-2c7ca3f8808935fc0c56458dca54f7bf417141f7.zip |
Showcase example
Diffstat (limited to 'examples/showcase/src/test/kotlin')
-rw-r--r-- | examples/showcase/src/test/kotlin/test/com/example/ShowcaseSpec.kt | 19 | ||||
-rw-r--r-- | examples/showcase/src/test/kotlin/test/com/example/TestUtil.kt | 32 |
2 files changed, 51 insertions, 0 deletions
diff --git a/examples/showcase/src/test/kotlin/test/com/example/ShowcaseSpec.kt b/examples/showcase/src/test/kotlin/test/com/example/ShowcaseSpec.kt new file mode 100644 index 00000000..64d46b18 --- /dev/null +++ b/examples/showcase/src/test/kotlin/test/com/example/ShowcaseSpec.kt @@ -0,0 +1,19 @@ +package test.com.example + +import com.example.Showcase +import kotlin.browser.document +import kotlin.test.Test +import kotlin.test.assertTrue + +class ShowcaseSpec : DomSpec { + + @Test + fun render() { + run { + Showcase().start(mapOf()) + val element = document.getElementById("showcase") + assertTrue(true, "True" + ) + } + } +} diff --git a/examples/showcase/src/test/kotlin/test/com/example/TestUtil.kt b/examples/showcase/src/test/kotlin/test/com/example/TestUtil.kt new file mode 100644 index 00000000..06d25a26 --- /dev/null +++ b/examples/showcase/src/test/kotlin/test/com/example/TestUtil.kt @@ -0,0 +1,32 @@ +package test.com.example + +import pl.treksoft.jquery.jQuery +import kotlin.browser.document + +interface TestSpec { + fun beforeTest() + + fun afterTest() + + fun run(code: () -> Unit) { + beforeTest() + code() + afterTest() + } +} + +interface DomSpec : TestSpec { + + override fun beforeTest() { + val fixture = "<div style=\"display: none\" id=\"pretest\">" + + "<div id=\"showcase\"></div></div>" + document.body?.insertAdjacentHTML("afterbegin", fixture) + } + + override fun afterTest() { + val div = document.getElementById("pretest") + div?.remove() + jQuery(`object` = ".modal-backdrop").remove() + } + +} |