From eddd58f3f31954809645bdf2222833424c3f9a73 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 8 Oct 2018 21:56:05 +0200 Subject: Testing modules. --- .../pl/treksoft/kvision/dropdown/DropDownSpec.kt | 132 --------------------- .../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 ---------- .../test/pl/treksoft/kvision/panel/RootSpec.kt | 14 --- .../test/pl/treksoft/kvision/window/WindowSpec.kt | 54 --------- 7 files changed, 423 deletions(-) delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.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/window/WindowSpec.kt (limited to 'src/test/kotlin') 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 9aa088fd..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", true) - 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", true) - 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", true) - 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", true) - 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", true) - 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", true) - 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/modal/AlertSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt deleted file mode 100644 index 807f837a..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", true) - 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 2e3ea3ef..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", true) - 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 dc734e10..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", true) - 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 523abfd5..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", true) - 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", true) - 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/RootSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt index d90abbe8..9e4342cc 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/panel/RootSpec.kt @@ -56,18 +56,4 @@ class RootSpec : DomSpec { assertTrue("Should return self") { r == root } } } - - @Test - fun addModal() { - run { - val root = Root("test", true) - 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/window/WindowSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt deleted file mode 100644 index fde2335d..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", true) - 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