From a4343ed3c4021db99de0fbc3f7c76929ad758265 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Fri, 10 Nov 2017 11:06:05 +0100 Subject: RichText form components --- .../kvision/form/text/RichTextInputSpec.kt | 28 +++++++++++++++++++ .../pl/treksoft/kvision/form/text/RichTextSpec.kt | 31 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt (limited to 'src/test') 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("", 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("", content, "Should render correct html area form field") + val label = document.getElementById("test")?.let { jQuery(it).find("label")[0]?.outerHTML } + assertEquals("", label, "Should render correct label for html area form field") + } + } + +} \ No newline at end of file -- cgit