From 107481f9ad5783daed68de8dadea65be57a6266b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 1 Mar 2018 14:21:24 +0100 Subject: Site initial commit --- .../test/pl/treksoft/kvision/KVManagerSpec.kt | 78 -------- .../kotlin/test/pl/treksoft/kvision/TestUtil.kt | 99 ----------- .../test/pl/treksoft/kvision/core/ContainerSpec.kt | 123 ------------- .../test/pl/treksoft/kvision/core/WidgetSpec.kt | 140 --------------- .../pl/treksoft/kvision/core/WidgetWrapperSpec.kt | 53 ------ .../pl/treksoft/kvision/data/DataContainerSpec.kt | 68 ------- .../pl/treksoft/kvision/dropdown/DropDownSpec.kt | 132 -------------- .../pl/treksoft/kvision/form/FieldLabelSpec.kt | 47 ----- .../test/pl/treksoft/kvision/form/FormPanelSpec.kt | 196 --------------------- .../test/pl/treksoft/kvision/form/FormSpec.kt | 196 --------------------- .../test/pl/treksoft/kvision/form/HelpBlockSpec.kt | 47 ----- .../pl/treksoft/kvision/form/check/CheckBoxSpec.kt | 63 ------- .../treksoft/kvision/form/check/CheckInputSpec.kt | 71 -------- .../treksoft/kvision/form/check/RadioGroupSpec.kt | 54 ------ .../pl/treksoft/kvision/form/check/RadioSpec.kt | 62 ------- .../kvision/form/select/SelectInputSpec.kt | 53 ------ .../kvision/form/select/SelectOptGroupSpec.kt | 54 ------ .../kvision/form/select/SelectOptionSpec.kt | 59 ------- .../pl/treksoft/kvision/form/select/SelectSpec.kt | 58 ------ .../kvision/form/spinner/SpinnerInputSpec.kt | 75 -------- .../treksoft/kvision/form/spinner/SpinnerSpec.kt | 82 --------- .../pl/treksoft/kvision/form/text/PasswordSpec.kt | 53 ------ .../kvision/form/text/RichTextInputSpec.kt | 51 ------ .../pl/treksoft/kvision/form/text/RichTextSpec.kt | 58 ------ .../kvision/form/text/TextAreaInputSpec.kt | 53 ------ .../pl/treksoft/kvision/form/text/TextAreaSpec.kt | 53 ------ .../pl/treksoft/kvision/form/text/TextInputSpec.kt | 54 ------ .../test/pl/treksoft/kvision/form/text/TextSpec.kt | 59 ------- .../kvision/form/time/DateTimeInputSpec.kt | 53 ------ .../pl/treksoft/kvision/form/time/DateTimeSpec.kt | 62 ------- .../test/pl/treksoft/kvision/html/ButtonSpec.kt | 51 ------ .../test/pl/treksoft/kvision/html/DivSpec.kt | 43 ----- .../test/pl/treksoft/kvision/html/ImageSpec.kt | 51 ------ .../test/pl/treksoft/kvision/html/LabelSpec.kt | 43 ----- .../test/pl/treksoft/kvision/html/LinkSpec.kt | 47 ----- .../test/pl/treksoft/kvision/html/ListSpec.kt | 67 ------- .../test/pl/treksoft/kvision/html/TagSpec.kt | 81 --------- .../test/pl/treksoft/kvision/modal/AlertSpec.kt | 59 ------- .../pl/treksoft/kvision/modal/CloseIconSpec.kt | 47 ----- .../test/pl/treksoft/kvision/modal/ConfirmSpec.kt | 55 ------ .../test/pl/treksoft/kvision/modal/ModalSpec.kt | 62 ------- .../pl/treksoft/kvision/panel/DockPanelSpec.kt | 53 ------ .../pl/treksoft/kvision/panel/FlexPanelSpec.kt | 52 ------ .../pl/treksoft/kvision/panel/GridPanelSpec.kt | 50 ------ .../test/pl/treksoft/kvision/panel/HPanelSpec.kt | 51 ------ .../kvision/panel/ResponsiveGridPanelSpec.kt | 50 ------ .../test/pl/treksoft/kvision/panel/RootSpec.kt | 73 -------- .../pl/treksoft/kvision/panel/SplitPanelSpec.kt | 53 ------ .../pl/treksoft/kvision/panel/StackPanelSpec.kt | 98 ----------- .../test/pl/treksoft/kvision/panel/TabPanelSpec.kt | 92 ---------- .../test/pl/treksoft/kvision/panel/VPanelSpec.kt | 51 ------ .../test/pl/treksoft/kvision/utils/UtilsSpec.kt | 75 -------- .../test/pl/treksoft/kvision/window/WindowSpec.kt | 54 ------ 53 files changed, 3664 deletions(-) delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/KVManagerSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/core/ContainerSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/core/WidgetWrapperSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/data/DataContainerSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/FieldLabelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/FormPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/FormSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/HelpBlockSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckBoxSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/CheckInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioGroupSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/check/RadioSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptGroupSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectOptionSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/select/SelectSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/PasswordSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/RichTextSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/TextAreaSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/TextInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/text/TextSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeInputSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/form/time/DateTimeSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/ButtonSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/DivSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/ImageSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/LabelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/LinkSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/TagSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/modal/CloseIconSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/modal/ConfirmSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/modal/ModalSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/DockPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/FlexPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/GridPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/HPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/SplitPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/StackPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/panel/VPanelSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/utils/UtilsSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt (limited to 'src/test/kotlin') 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("

Virtual node

") - 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 = "
" + - "
" - 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( - "
", - 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( - "
First
Second
", - element?.innerHTML, - "Should render correct data container" - ) - model.add(Model("Third")) - assertEqualsHtml( - "
First
Second
Third
", - element?.innerHTML, - "Should render correct data container after model change" - ) - model[1].value = "Changed" - assertEqualsHtml( - "
First
Changed
Third
", - 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( - "
", - 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( - "
", - 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( - "
", - 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( - "
", - 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( - "
", - 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( - "", - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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( - "Form Error", - 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( - "
", - element?.innerHTML, - "Should render correct checkbox form control" - ) - ci.style = CheckBoxStyle.INFO - ci.circled = false - ci.inline = false - assertEqualsHtml( - "
", - 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( - "", - 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( - "", - 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().first().input.id - val rid2 = ci.getChildren().filterIsInstance().last().input.id - assertEqualsHtml( - "
", - element?.innerHTML, - "Should render correct radio button group form control" - ) - } - } - -} \ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/form/check/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( - "
", - element?.innerHTML, - "Should render correct radio button form control" - ) - ci.style = RadioStyle.INFO - ci.squared = true - ci.inline = false - assertEqualsHtml( - "
", - 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(""), - "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( - "", - element?.innerHTML, - "Should render correct select option group" - ) - selectOptGroup.add(SelectOption("test3", "Test 3")) - assertEqualsHtml( - "", - 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( - "", - element?.innerHTML, - "Should render correct select option" - ) - selectOption.icon = "fa-flag" - assertEqualsHtml( - "", - element?.innerHTML, - "Should render correct select option with icon" - ) - selectOption.divider = true - assertEqualsHtml( - "", - 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("
"), - "Should render correct select form control" - ) - assertTrue( - true == element?.innerHTML?.endsWith("
"), - "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( - "
", - element?.innerHTML, - "Should render correct spinner input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "
Validation Error
", - 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( - "
", - 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("Field", - 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( - "", - 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( - "
", - 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( - "", - 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( - "
", - element?.innerHTML, - "Should render correct input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "
Validation Error
", - 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( - "
", - element?.innerHTML, - "Should render correct date time input form control" - ) - ti.validatorError = "Validation Error" - assertEqualsHtml( - "
Validation Error
", - 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( - "", - 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("
This is a 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( - "\"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("This is a label", 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( - "Google", - 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( - "
a1
a2
b1
b2
", - 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( - "
  • pre
  • del
", - 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 h1", rich = false, align = Align.CENTER) - root.add(tag) - val element = document.getElementById("test") - assertEqualsHtml( - "

This is <b>h1</b>

", - element?.innerHTML, - "Should render correct html tag" - ) - } - } - - @Test - fun renderRich() { - run { - val root = Root("test") - val tag = Tag(TAG.H1, "This is h1", rich = true, align = Align.RIGHT) - root.add(tag) - val element = document.getElementById("test") - assertEqualsHtml( - "

This is 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( - "

This is testabc

", - 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("
Alert content
", body, "Should render alert window with correct content") - val footer = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").html() } - assertEqualsHtml( - "", - 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( - "", - 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("
Confirm content
", 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( - "
def
jkl
mno
abc
ghi
", - 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( - "
abc
def
ghi
", - 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( - "
abc
def
ghi
", - 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( - "
abc
def
ghi
", - 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( - "
abc
def
ghi
", - 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( - "
abc
def
", - 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("
def
", 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( - "
abc
", - 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("
def
", 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("
", 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( - "", - 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( - "", - 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( - "
abc
", - 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( - "
abc
def
ghi
", - 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( - "

Window title

", - element?.innerHTML, - "Should render floating window without resizable handler" - ) - window.isResizable = true - assertEqualsHtml( - "

Window title

", - element?.innerHTML, - "Should render floating window with resizable handler" - ) - } - } - -} \ No newline at end of file -- cgit