summaryrefslogtreecommitdiff
path: root/src/test/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/kotlin')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt
new file mode 100644
index 00000000..1ba7f97b
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt
@@ -0,0 +1,38 @@
+package test.pl.treksoft.kvision.html
+
+import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.html.ALIGN
+import pl.treksoft.kvision.html.TAG
+import pl.treksoft.kvision.html.Tag
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class TagSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = false, align = ALIGN.CENTER)
+ root.add(tag)
+ val element = document.getElementById("test")
+ assertEquals("<h1 class=\"text-center\">This is &lt;b&gt;h1&lt;/b&gt;</h1>", element?.innerHTML, "Should render correct html tag")
+ }
+ }
+
+ @Test
+ fun render_rich() {
+ run {
+ val root = Root("test")
+ val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = true, align = ALIGN.CENTER)
+ root.add(tag)
+ val element = document.getElementById("test")
+ assertEquals("<h1 class=\"text-center\"><span>This is <b>h1</b></span></h1>", element?.innerHTML, "Should render correct html tag")
+ }
+ }
+
+
+} \ No newline at end of file