aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-11-10 11:06:05 +0100
committerRobert Jaros <rjaros@finn.pl>2017-11-10 11:06:05 +0100
commita4343ed3c4021db99de0fbc3f7c76929ad758265 (patch)
tree34d4b474a1ca3f2a74d7fa350572586396a4ed9c /src/test
parent25ab470ea458b2652ff77e2a66a856c63553c486 (diff)
downloadkvision-a4343ed3c4021db99de0fbc3f7c76929ad758265.tar.gz
kvision-a4343ed3c4021db99de0fbc3f7c76929ad758265.tar.bz2
kvision-a4343ed3c4021db99de0fbc3f7c76929ad758265.zip
RichText form components
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt28
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt31
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt
new file mode 100644
index 00000000..c2a3a6ee
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt
@@ -0,0 +1,28 @@
+package test.pl.treksoft.kvision.form.text
+
+import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.form.text.RichTextInput
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class RichTextInputSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val hai = RichTextInput(value = "abc").apply {
+ placeholder = "place"
+ id = "idti"
+ }
+ root.add(hai)
+ val id = document.getElementById("test")?.let { jQuery(it).find("trix-editor").attr("trix-id") } ?: "0"
+ val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML }
+ assertEquals("<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"idti\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", content, "Should render correct html area field")
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt
new file mode 100644
index 00000000..24851007
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt
@@ -0,0 +1,31 @@
+package test.pl.treksoft.kvision.form.text
+
+import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.core.Root
+import pl.treksoft.kvision.form.text.RichText
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class RichTextSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test")
+ val hai = RichText(value = "abc", label = "Field").apply {
+ placeholder = "place"
+ id = "idti"
+ }
+ root.add(hai)
+ val id = document.getElementById("test")?.let { jQuery(it).find("trix-editor").attr("trix-id") } ?: "0"
+ val iid = hai.input.id
+ val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML }
+ assertEquals("<trix-editor contenteditable=\"\" class=\"form-control trix-control\" id=\"$iid\" placeholder=\"place\" trix-id=\"$id\" input=\"trix-input-$id\" toolbar=\"trix-toolbar-$id\"></trix-editor>", content, "Should render correct html area form field")
+ val label = document.getElementById("test")?.let { jQuery(it).find("label")[0]?.outerHTML }
+ assertEquals("<label for=\"$iid\">Field</label>", label, "Should render correct label for html area form field")
+ }
+ }
+
+} \ No newline at end of file