aboutsummaryrefslogtreecommitdiff
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/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