aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-03-27 19:30:06 +0100
committerRobert Jaros <rjaros@finn.pl>2020-03-27 19:39:01 +0100
commitd7cb91657c5751d285afe51af9494ed362d9b5ca (patch)
tree91916682b7d640c3895a1ffb726519242c881d0c /src/test
parent4f111976f842b9a63363181ad2182091bb810c46 (diff)
downloadkvision-d7cb91657c5751d285afe51af9494ed362d9b5ca.tar.gz
kvision-d7cb91657c5751d285afe51af9494ed362d9b5ca.tar.bz2
kvision-d7cb91657c5751d285afe51af9494ed362d9b5ca.zip
Add support for custom html elements and custom css styles (#144)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/core/StyleSpec.kt3
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/html/CustomTagSpec.kt48
2 files changed, 50 insertions, 1 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/StyleSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/StyleSpec.kt
index cac53e90..33e08c1e 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/core/StyleSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/core/StyleSpec.kt
@@ -43,12 +43,13 @@ class StyleSpec : DomSpec {
margin = 2.px
color = Color.name(Col.SILVER)
overflow = Overflow.SCROLL
+ setStyle("box-shadow", "10px 10px")
}
}
}
val element = document.getElementById("test")
assertEqualsHtml(
- "<style>.kv_styleclass_0 {\noverflow: scroll;\nmargin: 2px;\ncolor: silver;\n}</style><div class=\"kv_styleclass_0\"></div>",
+ "<style>.kv_styleclass_0 {\noverflow: scroll;\nmargin: 2px;\ncolor: silver;\nbox-shadow: 10px 10px;\n}</style><div class=\"kv_styleclass_0\"></div>",
element?.innerHTML,
"Should render correct style element"
)
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/CustomTagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/CustomTagSpec.kt
new file mode 100644
index 00000000..d1261fa6
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/html/CustomTagSpec.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package test.pl.treksoft.kvision.html
+
+import pl.treksoft.kvision.html.Align
+import pl.treksoft.kvision.html.CustomTag
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class CustomTagSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val tag = CustomTag("custom-element", "This is <b>custom element</b>", rich = false, align = Align.CENTER)
+ root.add(tag)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<custom-element class=\"text-center\">This is &lt;b&gt;custom element&lt;/b&gt;</custom-element>",
+ element?.innerHTML,
+ "Should render correct custom html tag"
+ )
+ }
+ }
+
+}