diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-01 14:21:24 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-01 14:21:24 +0100 |
commit | 107481f9ad5783daed68de8dadea65be57a6266b (patch) | |
tree | 7f8063e5516585c12c599ce026c0d542b49ff985 /src/test/kotlin | |
parent | 8163f730f4b195160b5b9ca4202c1f304ac68b27 (diff) | |
download | kvision-107481f9ad5783daed68de8dadea65be57a6266b.tar.gz kvision-107481f9ad5783daed68de8dadea65be57a6266b.tar.bz2 kvision-107481f9ad5783daed68de8dadea65be57a6266b.zip |
Site initial commit
Diffstat (limited to 'src/test/kotlin')
53 files changed, 0 insertions, 3664 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/KVManagerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/KVManagerSpec.kt deleted file mode 100644 index 08ca430f..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/KVManagerSpec.kt +++ /dev/null @@ -1,78 +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 - -import com.github.snabbdom.h -import pl.treksoft.kvision.KVManager -import pl.treksoft.kvision.utils.snAttrs -import pl.treksoft.kvision.utils.snOpt -import pl.treksoft.kvision.utils.snStyle -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class KVManagerSpec : DomSpec { - - @Test - fun patchById() { - run { - val vnode = h("span", snOpt { - attrs = snAttrs(listOf("id" to "test_new")) - style = snStyle(listOf("fontWeight" to "bold", "fontStyle" to "italic")) - }) - KVManager.patch("test", vnode) - assertTrue("Original child should not exist") { document.getElementById("test") == null } - assertTrue("New child should exist") { document.getElementById("test_new") != null } - } - } - - @Test - fun patchByVnode() { - run { - val vnode1 = h("span", snOpt { - attrs = snAttrs(listOf("id" to "test2")) - style = snStyle(listOf("fontWeight" to "bold", "fontStyle" to "italic")) - }) - val vnode2 = KVManager.patch("test", vnode1) - val vnode3 = h("span", snOpt { - attrs = snAttrs(listOf("id" to "test3")) - style = snStyle(listOf("fontWeight" to "bold", "fontStyle" to "italic")) - }) - KVManager.patch(vnode2, vnode3) - assertTrue("First child should not exist") { document.getElementById("test") == null } - assertTrue("Second child should not exist") { document.getElementById("test2") == null } - assertTrue("Third child should exist") { document.getElementById("test3") != null } - } - } - - @Test - fun virtualize() { - run { - val node = KVManager.virtualize("<div id=\"virtual\"><p>Virtual node</p></div>") - KVManager.patch("test", node) - assertTrue("Original child should not exist") { document.getElementById("test") == null } - val v = document.getElementById("virtual") - assertTrue("New child should exist") { v != null } - assertTrue("New child should have one child") { v?.children?.length == 1 } - } - } -} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt deleted file mode 100644 index b67ab307..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt +++ /dev/null @@ -1,99 +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 - -import org.w3c.dom.Element -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.panel.Root -import kotlin.browser.document -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -interface TestSpec { - fun beforeTest() - - fun afterTest() - - fun run(code: () -> Unit) { - beforeTest() - code() - afterTest() - } -} - -interface SimpleSpec : TestSpec { - - override fun beforeTest() { - } - - override fun afterTest() { - } - -} - -interface DomSpec : TestSpec { - - override fun beforeTest() { - val fixture = "<div style=\"display: none\" id=\"pretest\">" + - "<div id=\"test\"></div></div>" - document.body?.insertAdjacentHTML("afterbegin", fixture) - } - - override fun afterTest() { - val div = document.getElementById("pretest") - div?.let { jQuery(it).remove() } - jQuery(`object` = ".modal-backdrop").remove() - } - - fun assertEqualsHtml(expected: String?, actual: String?, message: String?) { - if (expected != null && actual != null) { - val exp = jQuery(html = expected) - val act = jQuery(html = actual) - val result = exp[0]?.isEqualNode(act[0]) - if (result == true) { - assertTrue(result == true, message) - } else { - assertEquals(expected, actual, message) - } - } else { - assertEquals(expected, actual, message) - } - } -} - -interface WSpec : DomSpec { - - fun runW(code: (widget: Widget, element: Element?) -> Unit) { - run { - val root = Root("test") - val widget = Widget() - widget.id = "test_id" - root.add(widget) - val element = document.getElementById("test_id") - code(widget, element) - } - } - -} - -external fun require(name: String): dynamic diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt deleted file mode 100644 index 22735a64..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt +++ /dev/null @@ -1,123 +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.core - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.panel.SimplePanel -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class ContainerSpec : DomSpec { - - @Test - fun add() { - run { - val root = Root("test") - val container = SimplePanel() - val child1 = Widget() - child1.id = "child1" - val child2 = Widget() - child2.id = "child2" - container.add(child1) - container.add(child2) - root.add(container) - val elem1 = document.getElementById("child1") - val elem2 = document.getElementById("child2") - assertTrue("SimplePanel renders children") { elem1 != null && elem2 != null } - } - } - - @Test - fun addAll() { - run { - val root = Root("test") - val container = SimplePanel() - val child1 = Widget() - child1.id = "child1" - val child2 = Widget() - child2.id = "child2" - container.addAll(listOf(child1, child2)) - root.add(container) - val elem1 = document.getElementById("child1") - val elem2 = document.getElementById("child2") - assertTrue("SimplePanel renders children") { elem1 != null && elem2 != null } - } - } - - @Test - fun remove() { - run { - val root = Root("test") - val container = SimplePanel() - val child1 = Widget() - child1.id = "child1" - val child2 = Widget() - child2.id = "child2" - container.add(child1) - container.add(child2) - root.add(container) - container.remove(child2) - val elem1 = document.getElementById("child1") - val elem2 = document.getElementById("child2") - assertTrue("SimplePanel renders children") { elem1 != null && elem2 == null } - } - } - - @Test - fun removeAll() { - run { - val root = Root("test") - val container = SimplePanel() - val child1 = Widget() - child1.id = "child1" - val child2 = Widget() - child2.id = "child2" - container.add(child1) - container.add(child2) - root.add(container) - container.removeAll() - val elem1 = document.getElementById("child1") - val elem2 = document.getElementById("child2") - assertTrue("Children are not rendered") { elem1 == null && elem2 == null } - } - } - - @Test - fun getChildren() { - run { - val root = Root("test") - val container = SimplePanel() - val child1 = Widget() - child1.id = "child1" - val child2 = Widget() - child2.id = "child2" - container.add(child1) - container.add(child2) - root.add(container) - val childern = container.getChildren() - assertTrue("Returns children of current element") { childern.size == 2 } - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt deleted file mode 100644 index ceda72a9..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt +++ /dev/null @@ -1,140 +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.core - -import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.WSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class WidgetSpec : WSpec { - - @Test - fun renderVNode() { - runW { widget, _ -> - widget.addCssClass("testClass") - widget.title = "test_title" - val vnode = widget.renderVNode() - assertTrue("VNode has correct class attribute") { vnode.data.`class`.testClass == true } - assertTrue("VNode has correct id attribute") { vnode.data.attrs.id == "test_id" } - assertTrue("VNode has correct title attribute") { vnode.data.attrs.title == "test_title" } - } - } - - @Test - fun renderToDom() { - runW { widget, element -> - widget.addCssClass("testClass") - widget.title = "test_title" - assertTrue("New element should be created") { element != null } - assertTrue("New element should have correct css class") { element?.className == "testClass" } - assertTrue("New element should have correct id attribute") { element?.id == "test_id" } - assertTrue("New element should have correct title attribute") { element?.getAttribute("title") == "test_title" } - } - } - - @Test - fun hide() { - runW { widget, _ -> - widget.hide() - val element = document.getElementById("test_id") - assertTrue("Hidden element should not be accessible") { element == null } - } - } - - @Test - fun show() { - runW { widget, _ -> - widget.hide() - widget.show() - val element = document.getElementById("test_id") - assertTrue("Visible element should be accessible") { element != null } - } - } - - @Test - fun addCssClass() { - runW { widget, element -> - widget.addCssClass("test_class1") - widget.addCssClass("test_class2") - assertTrue("Element should have correct css classes") { element?.className == "test_class1 test_class2" } - } - } - - @Test - fun removeCssClass() { - runW { widget, element -> - widget.addCssClass("test_class1") - widget.addCssClass("test_class2") - widget.removeCssClass("test_class1") - assertTrue("Element should have correct css class") { element?.className == "test_class2" } - } - } - - @Test - fun setEventListener() { - runW { widget, _ -> - widget.setEventListener { click = { _ -> } } - assertTrue("Element should have an event listener") { widget.listeners.size == 1 } - } - } - - @Test - fun removeEventListener() { - runW { widget, _ -> - widget.setEventListener { click = { _ -> } } - widget.removeEventListeners() - assertTrue("Element should not have any event listener") { widget.listeners.size == 0 } - } - } - - @Test - fun getElement() { - runW { widget, element -> - val e = widget.getElement() - assertTrue("Should return correct dom element") { e == element } - } - } - - @Test - fun getElementJQuery() { - runW { widget, element -> - val j = widget.getElementJQuery() - assertTrue("Should return correct jQuery object") { j != null } - val e = j?.get()?.get(0) - assertTrue("Should return correct dom element from jQuery object") { e == element } - } - } - - @Test - fun getRoot() { - run { - val root = Root("test") - val widget = Widget() - root.add(widget) - val r = widget.getRoot() - assertTrue("Should return correct root element") { r == root } - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt deleted file mode 100644 index e2e6ef70..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt +++ /dev/null @@ -1,53 +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.core - -import pl.treksoft.kvision.core.UNIT -import pl.treksoft.kvision.core.Widget -import pl.treksoft.kvision.core.WidgetWrapper -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertEquals - -class WidgetWrapperSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val widget = Widget() - val wrapper = WidgetWrapper(widget) - wrapper.width = 100 to UNIT.em - root.add(wrapper) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"width: 100em;\"><div></div></div>", - element?.innerHTML, - "Should render widget inside custom wrapper" - ) - widget.hide() - assertEquals("", element?.innerHTML, "Should not render wrapper when widget is hidden") - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt deleted file mode 100644 index 809f5880..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt +++ /dev/null @@ -1,68 +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.data - -import com.lightningkite.kotlin.observable.list.observableListOf -import pl.treksoft.kvision.data.BaseDataComponent -import pl.treksoft.kvision.data.DataContainer -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class DataContainerSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - - class Model(value: String) : BaseDataComponent() { - var value: String by obs(value) - } - - val model = observableListOf(Model("First"), Model("Second")) - val container = DataContainer(model, { index -> Label(model[index].value) }) - root.add(container) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div></div>", - element?.innerHTML, - "Should render correct data container" - ) - model.add(Model("Third")) - assertEqualsHtml( - "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Second</span></div><div><span>Third</span></div></div>", - element?.innerHTML, - "Should render correct data container after model change" - ) - model[1].value = "Changed" - assertEqualsHtml( - "<div style=\"display: flex; flex-direction: column;\"><div><span>First</span></div><div><span>Changed</span></div><div><span>Third</span></div></div>", - element?.innerHTML, - "Should render correct data container after model element change" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt deleted file mode 100644 index 4d1b9334..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt +++ /dev/null @@ -1,132 +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.dropdown - -import pl.treksoft.kvision.dropdown.DD -import pl.treksoft.kvision.dropdown.DropDown -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class DropDownSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag") - root.add(dd) - dd.toggle() - val element = document.getElementById("test") - val id = dd.button.id - assertEqualsHtml( - "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", - element?.innerHTML, - "Should render correct drop down" - ) - } - } - - @Test - fun renderDropUp() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag").apply { dropup = true } - root.add(dd) - dd.toggle() - val element = document.getElementById("test") - val id = dd.button.id - assertEqualsHtml( - "<div class=\"dropup open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>", - element?.innerHTML, - "Should render correct drop down" - ) - } - } - - @Test - fun renderHeaderElement() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.option), "flag") - root.add(dd) - dd.toggle() - val element = document.getElementById("test") - val id = dd.button.id - assertEqualsHtml( - "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"dropdown-header\">abc</li></ul></div>", - element?.innerHTML, - "Should render correct drop down" - ) - } - } - - @Test - fun renderSeparatorElement() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.option), "flag") - root.add(dd) - dd.toggle() - val element = document.getElementById("test") - val id = dd.button.id - assertEqualsHtml( - "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", - element?.innerHTML, - "Should render correct drop down" - ) - } - } - - @Test - fun renderDisabledElement() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.option), "flag") - root.add(dd) - dd.toggle() - val element = document.getElementById("test") - val id = dd.button.id - assertEqualsHtml( - "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", - element?.innerHTML, - "Should render correct drop down" - ) - } - } - - @Test - fun toggle() { - run { - val root = Root("test") - val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag") - root.add(dd) - val visible = dd.getElementJQuery()?.hasClass("open") ?: false - assertTrue("Dropdown menu is not visible before toggle") { !visible } - dd.toggle() - val visible2 = dd.getElementJQuery()?.hasClass("open") ?: false - assertTrue("Dropdown menu is visible after toggle") { visible2 } - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt deleted file mode 100644 index 91a5d084..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt +++ /dev/null @@ -1,47 +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 - -import pl.treksoft.kvision.form.FieldLabel -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class FieldLabelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val fl = FieldLabel("input", "Label") - root.add(fl) - val element = document.getElementById("test") - assertEqualsHtml( - "<label class=\"control-label\" for=\"input\">Label</label>", - element?.innerHTML, - "Should render correct label" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt deleted file mode 100644 index 88695366..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt +++ /dev/null @@ -1,196 +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 - -import pl.treksoft.kvision.form.FormPanel -import pl.treksoft.kvision.form.text.Text -import pl.treksoft.kvision.form.time.DateTime -import test.pl.treksoft.kvision.SimpleSpec -import kotlin.js.Date -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -@Suppress("CanBeParameter") -class FormPanelSpec : SimpleSpec { - - @Test - fun add() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - formPanel.setData(data) - val result = formPanel.getData() - assertNull(result.a, "FormPanel should return null without adding any control") - val textField = Text() - formPanel.add("a", textField) - formPanel.setData(data) - val result2 = formPanel.getData() - assertEquals("Test value", result2.a, "FormPanel should return initial value") - } - } - - @Test - fun remove() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - formPanel.add("a", Text()) - formPanel.setData(data) - formPanel.remove("a") - val result = formPanel.getData() - assertNull(result.a, "FormPanel should return null after removing control") - } - } - - @Test - fun removeAll() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - formPanel.add("a", Text()) - formPanel.setData(data) - formPanel.removeAll() - val result = formPanel.getData() - assertNull(result.a, "FormPanel should return null after removing all controls") - } - } - - @Test - fun getControl() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - formPanel.add("a", Text()) - val control = formPanel.getControl("b") - assertNull(control, "Should return null when there is no such control") - val control2 = formPanel.getControl("a") - assertNotNull(control2, "Should return correct control") - } - } - - @Test - fun get() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - formPanel.add("a", Text()) - val b = formPanel["b"] - assertNull(b, "Should return null value when there is no added control") - val a = formPanel["a"] - assertNull(a, "Should return null value when control is empty") - formPanel.setData(data) - val a2 = formPanel["a"] - assertEquals("Test value", a2, "Should return correct value") - } - } - - @Test - fun getData() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - val textField = Text() - formPanel.add("a", textField) - formPanel.setData(data) - textField.value = "New value" - val result = formPanel.getData() - assertEquals("New value", result.a, "Form should return changed value") - } - } - - @Test - fun validate() { - run { - class DataForm(val map: Map<String, Any?>) { - val s: String? by map - val d: Date? by map - } - - val formPanel = FormPanel { - DataForm(it) - } - formPanel.add("s", Text()) { - it.getValue()?.length ?: 0 > 4 - } - formPanel.add("d", DateTime(), required = true) - formPanel.setData(DataForm(mapOf("s" to "123"))) - val valid = formPanel.validate() - assertEquals(false, valid, "Should be invalid with initial data") - formPanel.setData(DataForm(mapOf("s" to "12345"))) - val valid2 = formPanel.validate() - assertEquals(false, valid2, "Should be invalid with partially changed data") - formPanel.setData(DataForm(mapOf("s" to "12345", "d" to Date()))) - val valid3 = formPanel.validate() - assertEquals(true, valid3, "Should be valid") - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt deleted file mode 100644 index 128b96b1..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt +++ /dev/null @@ -1,196 +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 - -import pl.treksoft.kvision.form.Form -import pl.treksoft.kvision.form.text.Text -import pl.treksoft.kvision.form.time.DateTime -import test.pl.treksoft.kvision.SimpleSpec -import kotlin.js.Date -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -@Suppress("CanBeParameter") -class FormSpec : SimpleSpec { - - @Test - fun add() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - form.setData(data) - val result = form.getData() - assertNull(result.a, "Form should return null without adding any control") - val textField = Text() - form.add("a", textField) - form.setData(data) - val result2 = form.getData() - assertEquals("Test value", result2.a, "Form should return initial value") - } - } - - @Test - fun remove() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - form.add("a", Text()) - form.setData(data) - form.remove("a") - val result = form.getData() - assertNull(result.a, "Form should return null after removing control") - } - } - - @Test - fun removeAll() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - form.add("a", Text()) - form.setData(data) - form.removeAll() - val result = form.getData() - assertNull(result.a, "Form should return null after removing all controls") - } - } - - @Test - fun getControl() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - form.add("a", Text()) - val control = form.getControl("b") - assertNull(control, "Should return null when there is no such control") - val control2 = form.getControl("a") - assertNotNull(control2, "Should return correct control") - } - } - - @Test - fun get() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - form.add("a", Text()) - val b = form["b"] - assertNull(b, "Should return null value when there is no added control") - val a = form["a"] - assertNull(a, "Should return null value when control is empty") - form.setData(data) - val a2 = form["a"] - assertEquals("Test value", a2, "Should return correct value") - } - } - - @Test - fun getData() { - run { - class DataForm(val map: Map<String, Any?>) { - val a: String? by map - val b: Boolean? by map - val c: Date? by map - } - - val form = Form { - DataForm(it) - } - val data = DataForm(mapOf("a" to "Test value")) - val textField = Text() - form.add("a", textField) - form.setData(data) - textField.value = "New value" - val result = form.getData() - assertEquals("New value", result.a, "Form should return changed value") - } - } - - @Test - fun validate() { - run { - class DataForm(val map: Map<String, Any?>) { - val s: String? by map - val d: Date? by map - } - - val form = Form { - DataForm(it) - } - form.add("s", Text()) { - it.getValue()?.length ?: 0 > 4 - } - form.add("d", DateTime(), required = true) - form.setData(DataForm(mapOf("s" to "123"))) - val valid = form.validate() - assertEquals(false, valid, "Should be invalid with initial data") - form.setData(DataForm(mapOf("s" to "12345"))) - val valid2 = form.validate() - assertEquals(false, valid2, "Should be invalid with partially changed data") - form.setData(DataForm(mapOf("s" to "12345", "d" to Date()))) - val valid3 = form.validate() - assertEquals(true, valid3, "Should be valid") - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt deleted file mode 100644 index 69e7b8df..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt +++ /dev/null @@ -1,47 +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 - -import pl.treksoft.kvision.form.HelpBlock -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class HelpBlockSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val fl = HelpBlock("Form Error") - root.add(fl) - val element = document.getElementById("test") - assertEqualsHtml( - "<span class=\"help-block small\">Form Error</span>", - element?.innerHTML, - "Should render correct help block" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt deleted file mode 100644 index 95d53b3b..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt +++ /dev/null @@ -1,63 +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.CheckBox -import pl.treksoft.kvision.form.check.CheckBoxStyle -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class CheckBoxSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ci = CheckBox(value = true, label = "Label").apply { - name = "name" - style = CheckBoxStyle.DANGER - disabled = true - circled = true - inline = true - } - root.add(ci) - val element = document.getElementById("test") - val id = ci.input.id - assertEqualsHtml( - "<div class=\"checkbox checkbox-danger checkbox-circle checkbox-inline\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"checked\" name=\"name\" disabled=\"disabled\"><label for=\"$id\">Label</label></div>", - element?.innerHTML, - "Should render correct checkbox form control" - ) - ci.style = CheckBoxStyle.INFO - ci.circled = false - ci.inline = false - assertEqualsHtml( - "<div class=\"checkbox checkbox-info\"><input class=\"styled\" id=\"$id\" type=\"checkbox\" checked=\"checked\" name=\"name\" disabled=\"disabled\"><label for=\"$id\">Label</label></div>", - element?.innerHTML, - "Should render correct checkbox form 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 6b163047..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") - val ci = CheckInput(value = true).apply { - name = "name" - id = "idti" - disabled = true - } - root.add(ci) - val element = document.getElementById("test") - assertEqualsHtml( - "<input id=\"idti\" type=\"checkbox\" checked=\"checked\" name=\"name\" disabled=\"disabled\">", - element?.innerHTML, - "Should render correct checkbox control" - ) - } - } - - @Test - fun renderAsRadio() { - run { - val root = Root("test") - 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/RadioGroupSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt deleted file mode 100644 index 21a9bf41..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt +++ /dev/null @@ -1,54 +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.Radio -import pl.treksoft.kvision.form.check.RadioGroup -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class RadioGroupSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ci = RadioGroup(options = listOf("a" to "A", "b" to "B"), value = "a", label = "Label").apply { - disabled = true - inline = true - } - root.add(ci) - val element = document.getElementById("test") - val id = ci.flabel.forId - 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\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"radio\"><input id=\"$rid1\" type=\"radio\" name=\"$id\" disabled=\"disabled\" value=\"a\"><label for=\"$rid1\">A</label></div><div class=\"radio\"><input id=\"$rid2\" type=\"radio\" name=\"$id\" 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/RadioSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt deleted file mode 100644 index b43c2caa..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt +++ /dev/null @@ -1,62 +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.Radio -import pl.treksoft.kvision.form.check.RadioStyle -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class RadioSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ci = Radio(value = true, label = "Label", extraValue = "abc").apply { - name = "name" - style = RadioStyle.DANGER - disabled = true - inline = true - } - root.add(ci) - val element = document.getElementById("test") - val id = ci.input.id - assertEqualsHtml( - "<div class=\"radio radio-danger radio-inline\"><input id=\"$id\" type=\"radio\" checked=\"checked\" name=\"name\" disabled=\"disabled\" value=\"abc\"><label for=\"$id\">Label</label></div>", - element?.innerHTML, - "Should render correct radio button form control" - ) - ci.style = RadioStyle.INFO - ci.squared = true - ci.inline = false - assertEqualsHtml( - "<div class=\"checkbox kv-radio-checkbox checkbox-info\"><input id=\"$id\" type=\"radio\" checked=\"checked\" name=\"name\" disabled=\"disabled\" value=\"abc\"><label for=\"$id\">Label</label></div>", - element?.innerHTML, - "Should render correct radio button form control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt deleted file mode 100644 index 740c4032..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt +++ /dev/null @@ -1,53 +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.select - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.form.select.SelectWidthType -import pl.treksoft.kvision.form.select.SelectInput -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class SelectInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val selectInput = SelectInput(listOf("test1" to "Test 1", "test2" to "Test 2"), "test1", true).apply { - liveSearch = true - placeholder = "Choose ..." - selectWidthType = SelectWidthType.FIT - emptyOption = true - } - root.add(selectInput) - val element = document.getElementById("test") - assertTrue( - true == element?.innerHTML?.endsWith("<select class=\"selectpicker\" multiple=\"multiple\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div>"), - "Should render correct select input" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt deleted file mode 100644 index b906d09e..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt +++ /dev/null @@ -1,54 +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.select - -import pl.treksoft.kvision.form.select.SelectOptGroup -import pl.treksoft.kvision.form.select.SelectOption -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class SelectOptGroupSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val selectOptGroup = SelectOptGroup("Group", listOf("test1" to "Test 1", "test2" to "Test 2"), 2) - root.add(selectOptGroup) - val element = document.getElementById("test") - assertEqualsHtml( - "<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></optgroup>", - element?.innerHTML, - "Should render correct select option group" - ) - selectOptGroup.add(SelectOption("test3", "Test 3")) - assertEqualsHtml( - "<optgroup label=\"Group\" data-max-options=\"2\"><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option><option value=\"test3\">Test 3</option></optgroup>", - element?.innerHTML, - "Should render correct select option group with added option" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt deleted file mode 100644 index bbdfcd61..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt +++ /dev/null @@ -1,59 +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.select - -import pl.treksoft.kvision.form.select.SelectOption -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class SelectOptionSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val selectOption = SelectOption("testValue", "testLabel") - root.add(selectOption) - val element = document.getElementById("test") - assertEqualsHtml( - "<option value=\"testValue\">testLabel</option>", - element?.innerHTML, - "Should render correct select option" - ) - selectOption.icon = "fa-flag" - assertEqualsHtml( - "<option value=\"testValue\" data-icon=\"fa fa-flag\">testLabel</option>", - element?.innerHTML, - "Should render correct select option with icon" - ) - selectOption.divider = true - assertEqualsHtml( - "<option data-divider=\"true\"></option>", - element?.innerHTML, - "Should render correct divider option" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt deleted file mode 100644 index 15a01542..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt +++ /dev/null @@ -1,58 +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.select - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.form.select.SelectWidthType -import pl.treksoft.kvision.form.select.Select -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class SelectSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val select = Select(listOf("test1" to "Test 1", "test2" to "Test 2"), "test1", true, null, "Label").apply { - liveSearch = true - placeholder = "Choose ..." - selectWidthType = SelectWidthType.FIT - emptyOption = true - } - root.add(select) - val element = document.getElementById("test") - val id = select.input.id - assertTrue( - true == element?.innerHTML?.startsWith("<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label>"), - "Should render correct select form control" - ) - assertTrue( - true == element?.innerHTML?.endsWith("<select class=\"form-control selectpicker\" id=\"$id\" multiple=\"multiple\" data-live-search=\"true\" title=\"Choose ...\" data-style=\"btn-default\" data-width=\"fit\" tabindex=\"-98\"><option value=\"#kvnull\"></option><option value=\"test1\">Test 1</option><option value=\"test2\">Test 2</option></select></div></div>"), - "Should render correct select form control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt deleted file mode 100644 index 4e4151d7..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt +++ /dev/null @@ -1,75 +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.spinner - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.form.spinner.SpinnerInput -import test.pl.treksoft.kvision.DomSpec -import kotlin.test.Test -import kotlin.test.assertEquals - -class SpinnerInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val si = SpinnerInput(value = 13).apply { - placeholder = "place" - id = "idti" - } - root.add(si) - val value = si.getElementJQuery()?.`val`() - assertEquals("13", value, "Should render spinner input with correct value") - } - } - - @Test - fun spinUp() { - run { - val root = Root("test") - val si = SpinnerInput(value = 13).apply { - placeholder = "place" - id = "idti" - } - root.add(si) - assertEquals(13, si.value, "Should return initial value before spinUp") - si.spinUp() - assertEquals(14, si.value, "Should return changed value after spinUp") - } - } - - @Test - fun spinDown() { - run { - val root = Root("test") - val si = SpinnerInput(value = 13).apply { - placeholder = "place" - id = "idti" - } - root.add(si) - assertEquals(13, si.value, "Should return initial value before spinDown") - si.spinDown() - assertEquals(12, si.value, "Should return changed value after spinDown") - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt deleted file mode 100644 index fe2424f4..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt +++ /dev/null @@ -1,82 +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.spinner - -import pl.treksoft.kvision.form.spinner.Spinner -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertEquals - -class SpinnerSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = Spinner(value = 13, label = "Label").apply { - placeholder = "place" - name = "name" - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - val id = ti.input.id - assertEqualsHtml( - "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"disabled\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div></div>", - element?.innerHTML, - "Should render correct spinner input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><div class=\"input-group kv-spinner-btn-vertical\"><span><div class=\"input-group bootstrap-touchspin\"><span class=\"input-group-addon bootstrap-touchspin-prefix\" style=\"display: none;\"></span><input class=\"form-control\" id=\"$id\" type=\"text\" value=\"13\" placeholder=\"place\" name=\"name\" disabled=\"disabled\" style=\"display: block;\"><span class=\"input-group-addon bootstrap-touchspin-postfix\" style=\"display: none;\"></span><span class=\"input-group-btn-vertical\"><button class=\"btn btn-default bootstrap-touchspin-up\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-up\"></i></button><button class=\"btn btn-default bootstrap-touchspin-down\" type=\"button\"><i class=\"glyphicon glyphicon-chevron-down\"></i></button></span></div></span></div><span class=\"help-block small\">Validation Error</span></div>", - element?.innerHTML, - "Should render correct spinner input form control with validation error" - ) - } - } - - @Test - fun spinUp() { - run { - val root = Root("test") - val si = Spinner(value = 13) - root.add(si) - assertEquals(13, si.value, "Should return initial value before spinUp") - si.spinUp() - assertEquals(14, si.value, "Should return changed value after spinUp") - } - } - - @Test - fun spinDown() { - run { - val root = Root("test") - val si = Spinner(value = 13) - root.add(si) - assertEquals(13, si.value, "Should return initial value before spinDown") - si.spinDown() - assertEquals(12, si.value, "Should return changed value after spinDown") - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt deleted file mode 100644 index 3d1a90b7..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt +++ /dev/null @@ -1,53 +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.text - -import pl.treksoft.kvision.form.text.Password -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class PasswordSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = Password(value = "abc", label = "Label").apply { - placeholder = "place" - name = "name" - maxlength = 15 - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - val id = ti.input.id - assertEqualsHtml( - "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" type=\"password\" value=\"abc\"></div>", - element?.innerHTML, - "Should render correct input form control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt deleted file mode 100644 index e94af8d4..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt +++ /dev/null @@ -1,51 +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.text - -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.form.text.RichTextInput -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class RichTextInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val hai = RichTextInput(value = "abc").apply { - placeholder = "place" - id = "idti" - } - root.add(hai) - val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML } - assertTrue( - content?.startsWith("<trix-editor") == true, - "Should render correct html area control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt deleted file mode 100644 index 7e922118..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt +++ /dev/null @@ -1,58 +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.text - -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.form.text.RichText -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class RichTextSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val hai = RichText(value = "abc", label = "Field").apply { - placeholder = "place" - id = "idti" - } - root.add(hai) - val iid = hai.input.id - val content = document.getElementById("test")?.let { jQuery(it).find("trix-editor")[0]?.outerHTML } - assertTrue( - content?.startsWith("<trix-editor") == true, - "Should render correct html area form control" - ) - val label = document.getElementById("test")?.let { jQuery(it).find("label")[0]?.outerHTML } - assertEqualsHtml( - "<label class=\"control-label\" for=\"$iid\">Field</label>", - label, - "Should render correct label for html area form control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt deleted file mode 100644 index ac2aba28..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt +++ /dev/null @@ -1,53 +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.text - -import pl.treksoft.kvision.form.text.TextAreaInput -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TextAreaInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = TextAreaInput(cols = 5, rows = 2, value = "abc").apply { - placeholder = "place" - name = "name" - maxlength = 15 - id = "idti" - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - assertEqualsHtml( - "<textarea class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" cols=\"5\" rows=\"2\">abc</textarea>", - element?.innerHTML, - "Should render correct input control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt deleted file mode 100644 index 8ee0a0f9..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt +++ /dev/null @@ -1,53 +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.text - -import pl.treksoft.kvision.form.text.TextArea -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TextAreaSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = TextArea(cols = 5, rows = 2, value = "abc", label = "Label").apply { - placeholder = "place" - name = "name" - maxlength = 15 - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - val id = ti.input.id - assertEqualsHtml( - "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><textarea class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" cols=\"5\" rows=\"2\">abc</textarea></div>", - element?.innerHTML, - "Should render correct input form control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt deleted file mode 100644 index 4ceefc16..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt +++ /dev/null @@ -1,54 +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.text - -import pl.treksoft.kvision.form.text.TextInput -import pl.treksoft.kvision.form.text.TextInputType -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TextInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = TextInput(type = TextInputType.PASSWORD, value = "abc").apply { - placeholder = "place" - name = "name" - maxlength = 15 - id = "idti" - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - assertEqualsHtml( - "<input class=\"form-control\" id=\"idti\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" type=\"password\" value=\"abc\">", - element?.innerHTML, - "Should render correct input control" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt deleted file mode 100644 index 5ee99907..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt +++ /dev/null @@ -1,59 +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.text - -import pl.treksoft.kvision.form.text.Text -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TextSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ti = Text(value = "abc", label = "Label").apply { - placeholder = "place" - name = "name" - maxlength = 15 - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - val id = ti.input.id - assertEqualsHtml( - "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" type=\"text\" value=\"abc\"></div>", - element?.innerHTML, - "Should render correct input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" placeholder=\"place\" name=\"name\" maxlength=\"15\" disabled=\"disabled\" type=\"text\" value=\"abc\"><span class=\"help-block small\">Validation Error</span></div>", - element?.innerHTML, - "Should render correct input form control with validation error" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt deleted file mode 100644 index 3a0f8773..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt +++ /dev/null @@ -1,53 +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.time - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.form.time.DateTimeInput -import pl.treksoft.kvision.utils.toStringF -import test.pl.treksoft.kvision.DomSpec -import kotlin.js.Date -import kotlin.test.Test -import kotlin.test.assertEquals - -class DateTimeInputSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val data = Date() - val dti = DateTimeInput(value = data).apply { - placeholder = "place" - id = "idti" - } - root.add(dti) - val value = dti.getElementJQuery()?.`val`() - assertEquals( - data.toStringF(dti.format), - value, - "Should render date time input with correctly formatted value" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt deleted file mode 100644 index ba4ed7cf..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt +++ /dev/null @@ -1,62 +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.time - -import pl.treksoft.kvision.form.time.DateTime -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.utils.toStringF -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.js.Date -import kotlin.test.Test - -class DateTimeSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val data = Date() - val ti = DateTime(value = data, label = "Label").apply { - placeholder = "place" - name = "name" - disabled = true - } - root.add(ti) - val element = document.getElementById("test") - val id = ti.input.id - val datastr = data.toStringF(ti.format) - assertEqualsHtml( - "<div class=\"form-group\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"disabled\" value=\"$datastr\"></div>", - element?.innerHTML, - "Should render correct date time input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "<div class=\"form-group has-error\"><label class=\"control-label\" for=\"$id\">Label</label><input class=\"form-control\" id=\"$id\" type=\"text\" placeholder=\"place\" name=\"name\" disabled=\"disabled\" value=\"$datastr\"><span class=\"help-block small\">Validation Error</span></div>", - element?.innerHTML, - "Should render correct date time input form control with validation error" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt deleted file mode 100644 index 9c989156..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt +++ /dev/null @@ -1,51 +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.html - -import pl.treksoft.kvision.html.Button -import pl.treksoft.kvision.html.ButtonSize -import pl.treksoft.kvision.html.ButtonStyle -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class ButtonSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val button = Button("Cancel", "fa-bars", ButtonStyle.PRIMARY) - button.size = ButtonSize.LARGE - button.block = true - root.add(button) - val element = document.getElementById("test") - assertEqualsHtml( - "<button class=\"btn btn-primary btn-lg btn-block\" type=\"button\"><i class=\"fa fa-bars\"></i> Cancel</button>", - element?.innerHTML, - "Should render correct html button" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/DivSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/DivSpec.kt deleted file mode 100644 index 7ee008ad..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/DivSpec.kt +++ /dev/null @@ -1,43 +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.html - -import pl.treksoft.kvision.html.Div -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class DivSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val div = Div("This is a div") - root.add(div) - val element = document.getElementById("test") - assertEqualsHtml("<div>This is a div</div>", element?.innerHTML, "Should render correct div") - } - } - -} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt deleted file mode 100644 index be53c128..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt +++ /dev/null @@ -1,51 +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.html - -import pl.treksoft.kvision.html.Image -import pl.treksoft.kvision.html.ImageShape -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import test.pl.treksoft.kvision.require -import kotlin.browser.document -import kotlin.test.Test - -class ImageSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val res = require("./img/placeholder.png") - @Suppress("UnsafeCastFromDynamic") - val image = Image(res, "Image", true, ImageShape.ROUNDED, true) - root.add(image) - val element = document.getElementById("test") - assertEqualsHtml( - "<img class=\"img-responsive center-block img-rounded\" src=\"$res\" alt=\"Image\">", - element?.innerHTML, - "Should render correct html image" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/LabelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/LabelSpec.kt deleted file mode 100644 index 99f1b01c..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/LabelSpec.kt +++ /dev/null @@ -1,43 +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.html - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class LabelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val label = Label("This is a label") - root.add(label) - val element = document.getElementById("test") - assertEqualsHtml("<span>This is a label</span>", element?.innerHTML, "Should render correct label") - } - } - -} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt deleted file mode 100644 index 4e3dec2d..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt +++ /dev/null @@ -1,47 +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.html - -import pl.treksoft.kvision.html.Link -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class LinkSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val link = Link("Google", "http://www.google.com") - root.add(link) - val element = document.getElementById("test") - assertEqualsHtml( - "<a href=\"http://www.google.com\">Google</a>", - element?.innerHTML, - "Should render correct html link" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt deleted file mode 100644 index b691ab1a..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt +++ /dev/null @@ -1,67 +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.html - -import pl.treksoft.kvision.html.ListTag -import pl.treksoft.kvision.html.ListType -import pl.treksoft.kvision.html.TAG -import pl.treksoft.kvision.html.Tag -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class ListSpec : DomSpec { - - @Test - fun renderElements() { - run { - val root = Root("test") - val list = ListTag(ListType.DL_HORIZ, listOf("a1", "a2", "b1", "b2")) - root.add(list) - val element = document.getElementById("test") - assertEqualsHtml( - "<dl class=\"dl-horizontal\"><dt>a1</dt><dd>a2</dd><dt>b1</dt><dd>b2</dd></dl>", - element?.innerHTML, - "Should render correct html list" - ) - } - } - - @Test - fun renderAsContainer() { - run { - val root = Root("test") - val list = ListTag(ListType.UL) - list.add(Tag(TAG.PRE, "pre")) - list.add(Tag(TAG.DEL, "del")) - root.add(list) - val element = document.getElementById("test") - assertEqualsHtml( - "<ul><li><pre>pre</pre></li><li><del>del</del></li></ul>", - element?.innerHTML, - "Should render correct html list" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt deleted file mode 100644 index 4ef79069..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt +++ /dev/null @@ -1,81 +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.html - -import pl.treksoft.kvision.html.Align -import pl.treksoft.kvision.html.Link -import pl.treksoft.kvision.html.TAG -import pl.treksoft.kvision.html.Tag -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TagSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = false, align = Align.CENTER) - root.add(tag) - val element = document.getElementById("test") - assertEqualsHtml( - "<h1 class=\"text-center\">This is <b>h1</b></h1>", - element?.innerHTML, - "Should render correct html tag" - ) - } - } - - @Test - fun renderRich() { - run { - val root = Root("test") - val tag = Tag(TAG.H1, "This is <b>h1</b>", rich = true, align = Align.RIGHT) - root.add(tag) - val element = document.getElementById("test") - assertEqualsHtml( - "<h1 class=\"text-right\"><span>This is <b>h1</b></span></h1>", - element?.innerHTML, - "Should render correct html tag" - ) - } - } - - @Test - fun renderAsContainer() { - run { - val root = Root("test") - val tag = Tag(TAG.P, align = Align.RIGHT) - tag.add(Tag(TAG.DEL, "This is test")) - tag.add(Link("abc", "/x")) - root.add(tag) - val element = document.getElementById("test") - assertEqualsHtml( - "<p class=\"text-right\"><del>This is test</del><a href=\"/x\">abc</a></p>", - element?.innerHTML, - "Should render correct html tag with children" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt deleted file mode 100644 index 8f6e79bc..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt +++ /dev/null @@ -1,59 +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.modal - -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.modal.Alert -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -class AlertSpec : DomSpec { - - @Test - fun render() { - run { - Root("test") - Alert.show("Alert caption", "Alert content") - val alert = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] } - assertNotNull(alert, "Should show alert window") - val title = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() } - assertEquals("Alert caption", title, "Should render alert window with correct caption") - val body = document.getElementById("test")?.let { jQuery(it).find(".modal-body").html() } - assertEquals("<div>Alert content</div>", body, "Should render alert window with correct content") - val footer = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").html() } - assertEqualsHtml( - "<button class=\"btn btn-primary\" type=\"button\"><span class=\"glyphicon glyphicon-ok\"></span> OK</button>", - footer, - "Should render alert window with correct footer" - ) - val button = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").find("button") } - button?.click() - val alert2 = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] } - assertNull(alert2, "Should hide alert window after clicking OK") - } - } -} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt deleted file mode 100644 index 49e359a7..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt +++ /dev/null @@ -1,47 +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.modal - -import pl.treksoft.kvision.modal.CloseIcon -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class CloseIconSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val ci = CloseIcon() - root.add(ci) - val element = document.getElementById("test") - assertEqualsHtml( - "<button class=\"close\" type=\"button\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>", - element?.innerHTML, - "Should render correct close icon" - ) - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt deleted file mode 100644 index b327fdb3..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt +++ /dev/null @@ -1,55 +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.modal - -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.modal.Confirm -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -class ConfirmSpec : DomSpec { - - @Test - fun render() { - run { - Root("test") - Confirm.show("Confirm caption", "Confirm content") - val confirm = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] } - assertNotNull(confirm, "Should show confirm window") - val title = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() } - assertEquals("Confirm caption", title, "Should render confirm window with correct caption") - val body = document.getElementById("test")?.let { jQuery(it).find(".modal-body").html() } - assertEquals("<div>Confirm content</div>", body, "Should render confirm window with correct content") - val buttons = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").find("button") } - assertEquals(2, buttons?.length, "Should render confirm window with two buttons") - val button = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").find("button")[0] } - button?.click() - val confirm2 = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] } - assertNull(confirm2, "Should hide confirm window after clicking YES") - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt deleted file mode 100644 index d886a574..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt +++ /dev/null @@ -1,62 +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.modal - -import pl.treksoft.jquery.jQuery -import pl.treksoft.kvision.modal.Modal -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNull - -class ModalSpec : DomSpec { - - @Test - fun render() { - run { - Root("test") - val modal = Modal("Modal") - modal.show() - val content = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() } - assertEquals("Modal", content, "Should render correct modal") - modal.hide() - } - } - - @Test - fun toggle() { - run { - Root("test") - val modal = Modal("Modal") - modal.toggle() - val content = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() } - assertEquals("Modal", content, "Should show modal after toggle") - modal.toggle() - val content2 = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() } - assertNull(content2, "Should hide modal after second toggle") - modal.hide() - } - } - -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt deleted file mode 100644 index 1eff4042..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt +++ /dev/null @@ -1,53 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.DockPanel -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.panel.Side -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class DockPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val dockPanel = DockPanel() - root.add(dockPanel) - dockPanel.add(Label("abc"), Side.UP) - dockPanel.add(Label("def"), Side.RIGHT) - dockPanel.add(Label("ghi"), Side.DOWN) - dockPanel.add(Label("jkl"), Side.LEFT) - dockPanel.add(Label("mno"), Side.CENTER) - val element = document.getElementById("test") - assertEqualsHtml( - "<div><div style=\"display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;\"><div style=\"order: 2;\"><div style=\"display: flex; justify-content: space-between; align-items: center;\"><div style=\"order: 3;\"><span>def</span></div><div style=\"order: 1;\"><span>jkl</span></div><div style=\"order: 2;\"><span>mno</span></div></div></div><div style=\"order: 1; align-self: center;\"><span>abc</span></div><div style=\"order: 3; align-self: center;\"><span>ghi</span></div></div></div>", - element?.innerHTML, - "Should render correct dock panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt deleted file mode 100644 index 60012891..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt +++ /dev/null @@ -1,52 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.FlexDir -import pl.treksoft.kvision.panel.FlexJustify -import pl.treksoft.kvision.panel.FlexPanel -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class FlexPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val flexPanel = FlexPanel(FlexDir.ROWREV, justify = FlexJustify.SPACEEVENLY) - root.add(flexPanel) - flexPanel.add(Label("abc"), 1) - flexPanel.add(Label("def"), 2) - flexPanel.add(Label("ghi"), 3) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"display: flex; flex-direction: row-reverse; justify-content: space-evenly;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", - element?.innerHTML, - "Should render correct flex panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt deleted file mode 100644 index e59f0977..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt +++ /dev/null @@ -1,50 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.GridPanel -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class GridPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val gridPanel = GridPanel() - root.add(gridPanel) - gridPanel.add(Label("abc"), 1, 1) - gridPanel.add(Label("def"), 2, 2) - gridPanel.add(Label("ghi"), 3, 3) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"display: grid;\"><div style=\"grid-column-start: 1; grid-row-start: 1;\"><span>abc</span></div><div style=\"grid-column-start: 2; grid-row-start: 2;\"><span>def</span></div><div style=\"grid-column-start: 3; grid-row-start: 3;\"><span>ghi</span></div></div>", - element?.innerHTML?.replace(" ", " "), - "Should render correct grid panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt deleted file mode 100644 index 192be8b7..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt +++ /dev/null @@ -1,51 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.FlexJustify -import pl.treksoft.kvision.panel.HPanel -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class HPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val hPanel = HPanel(justify = FlexJustify.SPACEBETWEEN) - root.add(hPanel) - hPanel.add(Label("abc"), 1) - hPanel.add(Label("def"), 2) - hPanel.add(Label("ghi"), 3) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"display: flex; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", - element?.innerHTML, - "Should render correct horizontal panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt deleted file mode 100644 index 03af514b..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt +++ /dev/null @@ -1,50 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.ResponsiveGridPanel -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class ResponsiveGridPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val rgPanel = ResponsiveGridPanel() - root.add(rgPanel) - rgPanel.add(Label("abc"), 1, 1) - rgPanel.add(Label("def"), 2, 2) - rgPanel.add(Label("ghi"), 3, 3) - val element = document.getElementById("test") - assertEqualsHtml( - "<div><div class=\"row\"></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>abc</span></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>def</span></div><div class=\"col-md-3\"></div></div><div class=\"row\"><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"></div><div class=\"col-md-3\"><span>ghi</span></div></div></div>", - element?.innerHTML, - "Should render correct responsive grid panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt deleted file mode 100644 index 50a73231..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt +++ /dev/null @@ -1,73 +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.panel - -import pl.treksoft.kvision.modal.Modal -import pl.treksoft.kvision.panel.Root -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test -import kotlin.test.assertTrue - -class RootSpec : DomSpec { - - @Test - fun getSnClass() { - run { - Root("test") - val rootElem = document.getElementById("test") - assertTrue("Standard root child has correct css class") { rootElem?.className == "container-fluid" } - } - } - - @Test - fun getSnClass_Fluid() { - run { - Root("test", fixed = true) - val rootElem = document.getElementById("test") - assertTrue("Fluid root child has correct css class") { rootElem?.className == "container" } - } - } - - @Test - fun getRoot() { - run { - val root = Root("test") - val r = root.getRoot() - assertTrue("Should return self") { r == root } - } - } - - @Test - fun addModal() { - run { - val root = Root("test") - val modal = Modal("test") - modal.id = "test_modal" - root.addModal(modal) - modal.show() - val elem = document.getElementById("test_modal") - assertTrue("Should render standard modal") { elem != null } - modal.hide() - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt deleted file mode 100644 index 65fee217..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt +++ /dev/null @@ -1,53 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.Direction -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.panel.SplitPanel -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class SplitPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val splitPanel = SplitPanel(Direction.VERTICAL) - root.add(splitPanel) - val label1 = Label("abc") - val label2 = Label("def") - splitPanel.add(label1) - splitPanel.add(label2) - val element = document.getElementById("test") - val id = splitPanel.splitter.id - assertEqualsHtml( - "<div class=\"splitpanel-vertical\"><span class=\"resizable\">abc</span><div class=\"splitter-vertical\" id=\"$id\" style=\"touch-action: none;\"></div><span>def</span></div>", - element?.innerHTML, - "Should render correct split panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt deleted file mode 100644 index 17e5b40f..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt +++ /dev/null @@ -1,98 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.panel.StackPanel -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class StackPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val stackPanel = StackPanel() - root.add(stackPanel) - val label1 = Label("abc") - val label2 = Label("def") - stackPanel.add(label1) - stackPanel.add(label2) - val element = document.getElementById("test") - assertEqualsHtml("<div><span>def</span></div>", element?.innerHTML, "Should render correct stack panel") - } - } - - @Test - fun renderNotActivateLast() { - run { - val root = Root("test") - val stackPanel = StackPanel(activateLast = false) - root.add(stackPanel) - val label1 = Label("abc") - val label2 = Label("def") - stackPanel.add(label1) - stackPanel.add(label2) - val element = document.getElementById("test") - assertEqualsHtml( - "<div><span>abc</span></div>", - element?.innerHTML, - "Should render correct stack panel with activateLast = false" - ) - } - } - - @Test - fun remove() { - run { - val root = Root("test") - val stackPanel = StackPanel(activateLast = false) - root.add(stackPanel) - val label1 = Label("abc") - val label2 = Label("def") - stackPanel.add(label1) - stackPanel.add(label2) - stackPanel.remove(label1) - val element = document.getElementById("test") - assertEqualsHtml("<div><span>def</span></div>", element?.innerHTML, "Should remove correct child widget") - } - } - - @Test - fun removeAll() { - run { - val root = Root("test") - val stackPanel = StackPanel(activateLast = false) - root.add(stackPanel) - val label1 = Label("abc") - val label2 = Label("def") - stackPanel.add(label1) - stackPanel.add(label2) - stackPanel.removeAll() - val element = document.getElementById("test") - assertEqualsHtml("<div></div>", element?.innerHTML, "Should remove all child widgets") - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt deleted file mode 100644 index 78022db8..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt +++ /dev/null @@ -1,92 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.panel.TabPanel -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class TabPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val tabs = TabPanel() - root.add(tabs) - val label1 = Label("abc") - val label2 = Label("def") - tabs.addTab("ABC", label1) - tabs.addTab("DEF", label2) - val element = document.getElementById("test") - assertEqualsHtml( - "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"active\"><a href=\"#\">ABC</a></li><li role=\"presentation\"><a href=\"#\">DEF</a></li></ul><div><span>abc</span></div></div>", - element?.innerHTML, - "Should render correct tabs" - ) - } - } - - @Test - fun setActiveIndex() { - run { - val root = Root("test") - val tabs = TabPanel() - root.add(tabs) - val label1 = Label("abc") - val label2 = Label("def") - tabs.addTab("ABC", label1) - tabs.addTab("DEF", label2) - tabs.activeIndex = 1 - val element = document.getElementById("test") - assertEqualsHtml( - "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"\"><a href=\"#\">ABC</a></li><li role=\"presentation\" class=\"active\"><a href=\"#\">DEF</a></li></ul><div><span>def</span></div></div>", - element?.innerHTML, - "Should change selected tab" - ) - } - } - - @Test - fun removeTab() { - run { - val root = Root("test") - val tabs = TabPanel() - root.add(tabs) - val label1 = Label("abc") - val label2 = Label("def") - tabs.addTab("ABC", label1) - tabs.addTab("DEF", label2) - tabs.activeIndex = 1 - tabs.removeTab(1) - val element = document.getElementById("test") - assertEqualsHtml( - "<div><ul class=\"nav nav-tabs\"><li role=\"presentation\" class=\"\"><a href=\"#\">ABC</a></li></ul><div><span>abc</span></div></div>", - element?.innerHTML, - "Should remove tab" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt deleted file mode 100644 index eeaf5358..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt +++ /dev/null @@ -1,51 +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.panel - -import pl.treksoft.kvision.html.Label -import pl.treksoft.kvision.panel.FlexJustify -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.panel.VPanel -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class VPanelSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val vPanel = VPanel(justify = FlexJustify.SPACEBETWEEN) - root.add(vPanel) - vPanel.add(Label("abc"), 1) - vPanel.add(Label("def"), 2) - vPanel.add(Label("ghi"), 3) - val element = document.getElementById("test") - assertEqualsHtml( - "<div style=\"display: flex; flex-direction: column; justify-content: space-between;\"><div style=\"order: 1;\"><span>abc</span></div><div style=\"order: 2;\"><span>def</span></div><div style=\"order: 3;\"><span>ghi</span></div></div>", - element?.innerHTML, - "Should render correct vertical panel" - ) - } - } -}
\ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt deleted file mode 100644 index 0ac15b70..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt +++ /dev/null @@ -1,75 +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.utils - -import pl.treksoft.kvision.utils.toDateF -import pl.treksoft.kvision.utils.toHexString -import pl.treksoft.kvision.utils.toStringF -import test.pl.treksoft.kvision.SimpleSpec -import kotlin.js.Date -import kotlin.test.Test -import kotlin.test.assertEquals - -class UtilsSpec : SimpleSpec { - - @Test - fun intToHexString() { - run { - val res = 0xabcdef.toHexString() - assertEquals("abcdef", res, "Should convert int value to hex string") - val res2 = 0x123456.toHexString() - assertEquals("123456", res2, "Should convert int value to hex string") - } - } - - @Test - fun toDateF() { - run { - val res = "2017-03-14 14:50:35".toDateF() - assertEquals( - js("new Date(2017,2,14,14,50,35).getTime()"), - res.getTime(), - "Should convert String value to Date" - ) - } - } - - @Test - fun toStringF() { - run { - val date = js("new Date()") - val res = Date().toStringF() - val y = date.getFullYear() - val m = date.getMonth() + 1 - val m2 = if (m < 10) "0$m" else "$m" - val d = date.getDate() - val d2 = if (d < 10) "0$d" else "$d" - val h = date.getHours() - val h2 = if (h < 10) "0$h" else "$h" - val min = date.getMinutes() - val min2 = if (min < 10) "0$min" else "$min" - val sec = date.getSeconds() - val sec2 = if (sec < 10) "0$sec" else "$sec" - assertEquals("$y-$m2-$d2 $h2:$min2:$sec2", res, "Should convert Date value to String") - } - } -} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt deleted file mode 100644 index 27de17de..00000000 --- a/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt +++ /dev/null @@ -1,54 +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.window - -import pl.treksoft.kvision.panel.Root -import pl.treksoft.kvision.window.Window -import test.pl.treksoft.kvision.DomSpec -import kotlin.browser.document -import kotlin.test.Test - -class WindowSpec : DomSpec { - - @Test - fun render() { - run { - val root = Root("test") - val window = Window("Window title", isResizable = false) - root.add(window) - val id = window.id - val element = document.getElementById("test") - assertEqualsHtml( - "<div class=\"modal-content kv-window\" id=\"$id\" style=\"width: auto; position: absolute; z-index: 1001; overflow: hidden;\"><div class=\"modal-header\"><h4 class=\"modal-title\">Window title</h4></div><div style=\"height: auto; overflow: auto;\"></div></div>", - element?.innerHTML, - "Should render floating window without resizable handler" - ) - window.isResizable = true - assertEqualsHtml( - "<div class=\"modal-content kv-window\" id=\"$id\" style=\"width: auto; position: absolute; z-index: 1001; overflow: hidden; resize: both; height: 10px;\"><div class=\"modal-header\"><h4 class=\"modal-title\">Window title</h4></div><div style=\"height: auto; overflow: auto; margin-bottom: 11px;\"></div><object style=\"display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;\" class=\"resize-sensor\" type=\"text/html\" data=\"about:blank\"></object></div>", - element?.innerHTML, - "Should render floating window with resizable handler" - ) - } - } - -}
\ No newline at end of file |