aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt39
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt38
2 files changed, 77 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt
new file mode 100644
index 00000000..90d5e058
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.form.upload
+
+import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.form.upload.UploadInput
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class UploadInputSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", true)
+ val upi = UploadInput(multiple = true).apply {
+ id = "idti"
+ }
+ root.add(upi)
+ val content = document.getElementById("test")?.let { jQuery(it).find("input.form-control")[0]?.outerHTML }
+ assertEqualsHtml(
+ "<input class=\"form-control\" id=\"idti\" type=\"file\" multiple=\"true\">",
+ content,
+ "Should render correct file input control for multiple files"
+ )
+ upi.multiple = false
+ val content2 = document.getElementById("test")?.let { jQuery(it).find("input.form-control")[0]?.outerHTML }
+ assertEqualsHtml(
+ "<input class=\"form-control\" id=\"idti\" type=\"file\">",
+ content2,
+ "Should render correct file input control for single file"
+ )
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt
new file mode 100644
index 00000000..d4553d1f
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+package test.pl.treksoft.kvision.form.upload
+
+import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.form.upload.Upload
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class UploadSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", true)
+ val upi = Upload(multiple = true)
+ val id = upi.input.id
+ root.add(upi)
+ val content = document.getElementById("test")?.let { jQuery(it).find("input.form-control")[0]?.outerHTML }
+ assertEqualsHtml(
+ "<input class=\"form-control\" id=\"$id\" type=\"file\" multiple=\"true\">",
+ content,
+ "Should render correct file input control for multiple files"
+ )
+ upi.multiple = false
+ val content2 = document.getElementById("test")?.let { jQuery(it).find("input.form-control")[0]?.outerHTML }
+ assertEqualsHtml(
+ "<input class=\"form-control\" id=\"$id\" type=\"file\">",
+ content2,
+ "Should render correct file input control for single file"
+ )
+ }
+ }
+
+}