diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-29 01:05:02 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-29 01:05:02 +0200 |
commit | 5ff62fa68f1c6d9693aeb4c27116b77c43e1a309 (patch) | |
tree | 98755ab99b1920ebfa22fd0e26229560b5a68f4f /src/test | |
parent | 8a1370e0f661d2c90fd5aed8e868341119a866cd (diff) | |
download | kvision-5ff62fa68f1c6d9693aeb4c27116b77c43e1a309.tar.gz kvision-5ff62fa68f1c6d9693aeb4c27116b77c43e1a309.tar.bz2 kvision-5ff62fa68f1c6d9693aeb4c27116b77c43e1a309.zip |
Components for file upload.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadInputSpec.kt | 39 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/upload/UploadSpec.kt | 38 |
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" + ) + } + } + +} |