p1
-p2
-p1
-p2
-p1
-p2
p3
- -OK
aaa", - document.serialize(false).trim().replace("\r\n", "\n")) - } - - @test fun testComment() { - val document = createHTMLDocument().html { - comment("commented") - } - - assertEquals("\n" + - "", - document.serialize(false).trim().replace("\r\n", "\n")) - } +package kotlinx.html.tests + +import kotlinx.html.* +import kotlinx.html.consumers.* +import kotlinx.html.dom.* +import kotlin.test.* +import org.junit.Test as test + +class TestDOMTrees { + @test fun `able to create simple tree`() { + val tree = createHTMLDocument().div { + id = "test-node" + +"content" + } + + assertEquals("div", tree.getElementById("test-node")?.tagName?.toLowerCase()) + } + + @test fun `able to create complex tree and render it with pretty print`() { + val tree = createHTMLDocument().html { + body { + h1 { + +"header" + } + div { + +"content" + span { + +"yo" + } + } + } + } + + assertEquals("\np1
+p2
+p1
++ p2 +
p3
+ +OK
aaa", + document.serialize(false).trim().replace("\r\n", "\n")) + } + + @test fun testComment() { + val document = createHTMLDocument().html { + comment("commented") + } + + assertEquals("\n" + + "", + document.serialize(false).trim().replace("\r\n", "\n")) + } } \ No newline at end of file diff --git a/jvm/src/test/kotlin/exceptions.kt b/src/jvmTest/kotlin/exceptions.kt similarity index 92% rename from jvm/src/test/kotlin/exceptions.kt rename to src/jvmTest/kotlin/exceptions.kt index b89046df..88c0eb71 100644 --- a/jvm/src/test/kotlin/exceptions.kt +++ b/src/jvmTest/kotlin/exceptions.kt @@ -1,9 +1,8 @@ import kotlinx.html.* -import kotlinx.html.consumers.catch -import kotlinx.html.stream.appendHTML +import kotlinx.html.consumers.* +import kotlinx.html.stream.* import org.junit.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue +import kotlin.test.* class TestExceptions { @Test fun `default exception must result in empty tag`() { diff --git a/jvm/src/test/kotlin/html5-tags.kt b/src/jvmTest/kotlin/html5-tags.kt similarity index 90% rename from jvm/src/test/kotlin/html5-tags.kt rename to src/jvmTest/kotlin/html5-tags.kt index 712b55fc..9b84f760 100644 --- a/jvm/src/test/kotlin/html5-tags.kt +++ b/src/jvmTest/kotlin/html5-tags.kt @@ -1,11 +1,8 @@ package kotlinx.html.tests import kotlinx.html.* -import kotlinx.html.consumers.filter import kotlinx.html.dom.* -import kotlinx.html.dom.createHTMLDocument -import kotlin.test.Test -import kotlin.test.assertEquals +import kotlin.test.* import org.junit.Test as test class Html5TagsTest { @@ -54,7 +51,8 @@ class Html5TagsTest {