From a54a54cef9035293f0bc55464cd1a96e5db128b9 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 2 Feb 2020 01:12:45 +0100 Subject: Add RangeInput and Range components (sliders) (#132) --- .../treksoft/kvision/form/range/RangeInputSpec.kt | 51 ++++++++++++++++++++++ .../pl/treksoft/kvision/form/range/RangeSpec.kt | 51 ++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeInputSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeSpec.kt (limited to 'src/test') diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeInputSpec.kt new file mode 100644 index 00000000..70f6d90a --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeInputSpec.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.select + +import pl.treksoft.kvision.form.range.RangeInput +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class RangeInputSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", fixed = true) + val ri = RangeInput(12, 10, 20, 2).apply { + name = "name" + id = "idri" + disabled = true + } + root.add(ri) + val element = document.getElementById("test") + assertEqualsHtml( + "", + element?.innerHTML, + "Should render correct range input control" + ) + } + } + +} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeSpec.kt new file mode 100644 index 00000000..26560293 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeSpec.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.select + +import pl.treksoft.kvision.form.range.Range +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class RangeSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", fixed = true) + val range = Range(12, "name", 10, 20, 2, "Label").apply { + id = "idri" + disabled = true + } + root.add(range) + val element = document.getElementById("test") + val id = range.input.id + assertEqualsHtml( + "
", + element?.innerHTML, + "Should render correct range form control" + ) + } + } + +} -- cgit