diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-01-16 18:39:15 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-01-16 18:39:15 +0100 |
commit | ea9d0452931934c6e0fdbdf7d7ad2ea7b7e6c070 (patch) | |
tree | ba48d5a9a8f506c2d1d9a1090cab7b2f41cecfe8 /src/test/kotlin | |
parent | 8f6de1f59e9aa8207e58e43b862c6d252f5341d3 (diff) | |
download | kvision-ea9d0452931934c6e0fdbdf7d7ad2ea7b7e6c070.tar.gz kvision-ea9d0452931934c6e0fdbdf7d7ad2ea7b7e6c070.tar.bz2 kvision-ea9d0452931934c6e0fdbdf7d7ad2ea7b7e6c070.zip |
Unification of class hierarchy in form.check package.
Diffstat (limited to 'src/test/kotlin')
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt (renamed from src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt) | 26 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupInputSpec.kt | 54 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioInputSpec.kt | 51 |
3 files changed, 108 insertions, 23 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt index 6cb1cd3e..8a9f86d5 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt @@ -21,20 +21,19 @@ */ package test.pl.treksoft.kvision.form.check -import pl.treksoft.kvision.form.check.CheckInput -import pl.treksoft.kvision.form.check.CheckInputType +import pl.treksoft.kvision.form.check.CheckBoxInput import pl.treksoft.kvision.panel.Root import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document import kotlin.test.Test -class CheckInputSpec : DomSpec { +class CheckBoxInputSpec : DomSpec { @Test fun render() { run { val root = Root("test", true) - val ci = CheckInput(value = true).apply { + val ci = CheckBoxInput(value = true).apply { name = "name" id = "idti" disabled = true @@ -49,23 +48,4 @@ class CheckInputSpec : DomSpec { } } - @Test - fun renderAsRadio() { - run { - val root = Root("test", true) - val ci = CheckInput(type = CheckInputType.RADIO, value = true).apply { - name = "name" - id = "idti" - extraValue = "abc" - } - root.add(ci) - val element = document.getElementById("test") - assertEqualsHtml( - "<input id=\"idti\" type=\"radio\" checked=\"checked\" name=\"name\" value=\"abc\">", - element?.innerHTML, - "Should render correct radio button control" - ) - } - } - }
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupInputSpec.kt new file mode 100644 index 00000000..f74a76f7 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupInputSpec.kt @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package test.pl.treksoft.kvision.form.check + +import pl.treksoft.kvision.form.check.Radio +import pl.treksoft.kvision.form.check.RadioGroupInput +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class RadioGroupInputSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", true) + val ci = RadioGroupInput(options = listOf("a" to "A", "b" to "B"), value = "a").apply { + disabled = true + inline = true + } + root.add(ci) + val element = document.getElementById("test") + val name = ci.getChildren().filterIsInstance<Radio>().first().input.name + val rid1 = ci.getChildren().filterIsInstance<Radio>().first().input.id + val rid2 = ci.getChildren().filterIsInstance<Radio>().last().input.id + assertEqualsHtml( + "<div class=\"form-group kv-radiogroup-inline\"><div class=\"radio\"><input id=\"$rid1\" type=\"radio\" name=\"$name\" disabled=\"disabled\" value=\"a\"><label for=\"$rid1\">A</label></div><div class=\"radio\"><input id=\"$rid2\" type=\"radio\" name=\"$name\" disabled=\"disabled\" value=\"b\"><label for=\"$rid2\">B</label></div></div>", + element?.innerHTML, + "Should render correct radio button group form control" + ) + } + } + +}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioInputSpec.kt new file mode 100644 index 00000000..55d4108a --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioInputSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package test.pl.treksoft.kvision.form.check + +import pl.treksoft.kvision.form.check.RadioInput +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class RadioInputSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", true) + val ci = RadioInput(value = true).apply { + name = "name" + id = "idti" + extraValue = "abc" + } + root.add(ci) + val element = document.getElementById("test") + assertEqualsHtml( + "<input id=\"idti\" type=\"radio\" checked=\"checked\" name=\"name\" value=\"abc\">", + element?.innerHTML, + "Should render correct radio button control" + ) + } + } + +}
\ No newline at end of file |