From 69a8b03ba9668be257e2db375d6ee58e51e367b7 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 9 May 2020 23:54:44 +0200 Subject: Add missing tests for new html components --- .../kotlin/test/pl/treksoft/kvision/html/LiSpec.kt | 43 ++++++++++++++ .../test/pl/treksoft/kvision/html/ListSpec.kt | 67 ---------------------- .../test/pl/treksoft/kvision/html/ListTagSpec.kt | 67 ++++++++++++++++++++++ .../test/pl/treksoft/kvision/html/NavSpec.kt | 43 ++++++++++++++ .../kotlin/test/pl/treksoft/kvision/html/OlSpec.kt | 47 +++++++++++++++ .../kotlin/test/pl/treksoft/kvision/html/UlSpec.kt | 47 +++++++++++++++ 6 files changed, 247 insertions(+), 67 deletions(-) create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/LiSpec.kt delete mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/ListSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/ListTagSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/NavSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/OlSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/html/UlSpec.kt (limited to 'src/test') diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/LiSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/LiSpec.kt new file mode 100644 index 00000000..6f18f60b --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/LiSpec.kt @@ -0,0 +1,43 @@ +/* + * 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.Li +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class LiSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + val li = Li("This is li element") + root.add(li) + val element = document.getElementById("test") + assertEqualsHtml("
  • This is li element
  • ", element?.innerHTML, "Should render correct li element") + } + } + +} 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 622b11e5..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", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) - 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", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) - 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( - "", - element?.innerHTML, - "Should render correct html list" - ) - } - } - -} \ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/ListTagSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/ListTagSpec.kt new file mode 100644 index 00000000..4ade5fc7 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/ListTagSpec.kt @@ -0,0 +1,67 @@ +/* + * 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 ListTagSpec : DomSpec { + + @Test + fun renderElements() { + run { + val root = Root("test", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + 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", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + 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( + "", + element?.innerHTML, + "Should render correct html list" + ) + } + } + +} \ No newline at end of file diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/NavSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/NavSpec.kt new file mode 100644 index 00000000..a299fe43 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/NavSpec.kt @@ -0,0 +1,43 @@ +/* + * 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.Nav +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class NavSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + val nav = Nav("This is nav element") + root.add(nav) + val element = document.getElementById("test") + assertEqualsHtml("", element?.innerHTML, "Should render correct nav element") + } + } + +} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/OlSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/OlSpec.kt new file mode 100644 index 00000000..eeb5e5da --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/OlSpec.kt @@ -0,0 +1,47 @@ +/* + * 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.Ol +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class OlSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + val ol = Ol(listOf("first", "second")) + root.add(ol) + val element = document.getElementById("test") + assertEqualsHtml( + "
    1. first
    2. second
    ", + element?.innerHTML, + "Should render correct ol list" + ) + } + } + +} diff --git a/src/test/kotlin/test/pl/treksoft/kvision/html/UlSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/html/UlSpec.kt new file mode 100644 index 00000000..5efcb7b9 --- /dev/null +++ b/src/test/kotlin/test/pl/treksoft/kvision/html/UlSpec.kt @@ -0,0 +1,47 @@ +/* + * 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.Ul +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class UlSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = pl.treksoft.kvision.panel.ContainerType.FIXED) + val ul = Ul(listOf("first", "second")) + root.add(ul) + val element = document.getElementById("test") + assertEqualsHtml( + "", + element?.innerHTML, + "Should render correct ul list" + ) + } + } + +} -- cgit