From ea9d0452931934c6e0fdbdf7d7ad2ea7b7e6c070 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Wed, 16 Jan 2019 18:39:15 +0100 Subject: Unification of class hierarchy in form.check package. --- .../kvision/form/check/CheckBoxInputSpec.kt | 51 ++++++++++++++++ .../treksoft/kvision/form/check/CheckInputSpec.kt | 71 ---------------------- .../kvision/form/check/RadioGroupInputSpec.kt | 54 ++++++++++++++++ .../treksoft/kvision/form/check/RadioInputSpec.kt | 51 ++++++++++++++++ 4 files changed, 156 insertions(+), 71 deletions(-) create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupInputSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioInputSpec.kt (limited to 'src/test') diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.kt new file mode 100644 index 00000000..8a9f86d5 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxInputSpec.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.CheckBoxInput +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class CheckBoxInputSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", true) + val ci = CheckBoxInput(value = true).apply { + name = "name" + id = "idti" + disabled = true + } + root.add(ci) + val element = document.getElementById("test") + assertEqualsHtml( + "", + element?.innerHTML, + "Should render correct checkbox control" + ) + } + } + +} \ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt deleted file mode 100644 index 6cb1cd3e..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.CheckInput -import pl.treksoft.kvision.form.check.CheckInputType -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class CheckInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test", true) - val ci = CheckInput(value = true).apply { - name = "name" - id = "idti" - disabled = true - } - root.add(ci) - val element = document.getElementById("test") - assertEqualsHtml( - "", - element?.innerHTML, - "Should render correct checkbox control" - ) - } - } - - @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( - "", - 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().first().input.name + val rid1 = ci.getChildren().filterIsInstance().first().input.id + val rid2 = ci.getChildren().filterIsInstance().last().input.id + assertEqualsHtml( + "
", + 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( + "", + element?.innerHTML, + "Should render correct radio button control" + ) + } + } + +} \ No newline at end of file -- cgit