diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-02-02 01:12:45 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-02-02 01:12:45 +0100 |
commit | a54a54cef9035293f0bc55464cd1a96e5db128b9 (patch) | |
tree | a9674c0b923cd77f0e8abaa59d71989fe4d11936 /src/test | |
parent | fcc1282b15e0d382df22bb849454d6653291647e (diff) | |
download | kvision-a54a54cef9035293f0bc55464cd1a96e5db128b9.tar.gz kvision-a54a54cef9035293f0bc55464cd1a96e5db128b9.tar.bz2 kvision-a54a54cef9035293f0bc55464cd1a96e5db128b9.zip |
Add RangeInput and Range components (sliders) (#132)
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeInputSpec.kt | 51 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/form/range/RangeSpec.kt | 51 |
2 files changed, 102 insertions, 0 deletions
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( + "<input class=\"form-control-range\" id=\"idri\" type=\"range\" value=\"12\" name=\"name\" min=\"10\" max=\"20\" step=\"2\" disabled=\"disabled\">", + 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( + "<div class=\"form-group\" id=\"idri\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control-range\" id=\"$id\" type=\"range\" value=\"12\" name=\"name\" min=\"10\" max=\"20\" step=\"2\" disabled=\"disabled\"></div>", + element?.innerHTML, + "Should render correct range form control" + ) + } + } + +} |