From c2716ef0aae16553655cab4ea24f685e49e5fee8 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 7 Jun 2020 23:17:31 +0200 Subject: OnsenUI carousel component. Basic tests for OnsenUI module (#126) --- .../pl/treksoft/kvision/onsenui/OnsenUISpec.kt | 40 ++++++++++++++ .../kvision/onsenui/carousel/CarouselItemSpec.kt | 54 +++++++++++++++++++ .../kvision/onsenui/carousel/CarouselSpec.kt | 51 ++++++++++++++++++ .../kvision/onsenui/core/BackButtonSpec.kt | 55 +++++++++++++++++++ .../treksoft/kvision/onsenui/core/NavigatorSpec.kt | 51 ++++++++++++++++++ .../pl/treksoft/kvision/onsenui/core/PageSpec.kt | 48 +++++++++++++++++ .../kvision/onsenui/splitter/SplitterSpec.kt | 62 ++++++++++++++++++++++ .../treksoft/kvision/onsenui/tabbar/TabbarSpec.kt | 59 ++++++++++++++++++++ .../kvision/onsenui/toolbar/BottomToolbarSpec.kt | 52 ++++++++++++++++++ .../kvision/onsenui/toolbar/ToolbarButtonSpec.kt | 54 +++++++++++++++++++ .../kvision/onsenui/toolbar/ToolbarSpec.kt | 52 ++++++++++++++++++ 11 files changed, 578 insertions(+) create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/OnsenUISpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselItemSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/BackButtonSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/NavigatorSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/PageSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/splitter/SplitterSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/tabbar/TabbarSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/BottomToolbarSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarButtonSpec.kt create mode 100644 kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarSpec.kt (limited to 'kvision-modules/kvision-onsenui/src/test/kotlin') diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/OnsenUISpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/OnsenUISpec.kt new file mode 100644 index 00000000..8c97a29b --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/OnsenUISpec.kt @@ -0,0 +1,40 @@ +/* + * 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.onsenui + +import pl.treksoft.kvision.onsenui.OnsenUi +import pl.treksoft.kvision.onsenui.Platform +import test.pl.treksoft.kvision.DomSpec +import kotlin.test.Test +import kotlin.test.assertEquals + +class OnsenUISpec : DomSpec { + + @Test + fun isChrome() { + run { + OnsenUi.platformSelect(Platform.CHROME) + val isChrome = OnsenUi.isChrome() + assertEquals(true, isChrome, "Should detect the correct platform") + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselItemSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselItemSpec.kt new file mode 100644 index 00000000..da6caf11 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselItemSpec.kt @@ -0,0 +1,54 @@ +/* + * 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.onsenui.carousel + +import pl.treksoft.kvision.onsenui.carousel.carousel +import pl.treksoft.kvision.onsenui.carousel.carouselItem +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class CarouselItemSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + carousel { + carouselItem("item 1") + carouselItem("item 2") + } + } + + val element = document.getElementById("test") + assertEqualsHtml( + "
item 1item 2
", + element?.innerHTML, + "Should render Onsen UI carousel component with items" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselSpec.kt new file mode 100644 index 00000000..dc2d21b6 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package test.pl.treksoft.kvision.onsenui.carousel + +import pl.treksoft.kvision.onsenui.carousel.carousel +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class CarouselSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + carousel { + } + } + + val element = document.getElementById("test") + assertEqualsHtml( + "
", + element?.innerHTML, + "Should render Onsen UI carousel component" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/BackButtonSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/BackButtonSpec.kt new file mode 100644 index 00000000..16b57da2 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/BackButtonSpec.kt @@ -0,0 +1,55 @@ +/* + * 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.onsenui.core + +import pl.treksoft.kvision.onsenui.core.backButton +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.toolbar.toolbar +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class BackButtonSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + toolbar { + left { + backButton() + } + } + } + + val element = document.getElementById("test") + assertEqualsHtml( + "
", + element?.innerHTML, + "Should render Onsen UI back button component" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/NavigatorSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/NavigatorSpec.kt new file mode 100644 index 00000000..c95bf536 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/NavigatorSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package test.pl.treksoft.kvision.onsenui.core + +import pl.treksoft.kvision.onsenui.core.navigator +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.panel.ContainerType +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 NavigatorSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.navigator { + page { + } + } + + val element = document.getElementById("test") + assertTrue( + element?.innerHTML?.contains("
", + element?.innerHTML, + "Should render Onsen UI page component" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/splitter/SplitterSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/splitter/SplitterSpec.kt new file mode 100644 index 00000000..92fe7ad9 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/splitter/SplitterSpec.kt @@ -0,0 +1,62 @@ +/* + * 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.onsenui.splitter + +import pl.treksoft.kvision.html.div +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.splitter.splitter +import pl.treksoft.kvision.onsenui.splitter.splitterContent +import pl.treksoft.kvision.onsenui.splitter.splitterSide +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class SplitterSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.splitter { + splitterSide { + page { + div("menu") + } + } + splitterContent { + page { + div("content") + } + } + } + + val element = document.getElementById("test") + assertEqualsHtml( + "
menu
content
", + element?.innerHTML, + "Should render Onsen UI splitter component" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/tabbar/TabbarSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/tabbar/TabbarSpec.kt new file mode 100644 index 00000000..80c55be2 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/tabbar/TabbarSpec.kt @@ -0,0 +1,59 @@ +/* + * 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.onsenui.tabbar + +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.tabbar.tab +import pl.treksoft.kvision.onsenui.tabbar.tabbar +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class TabbarSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + tabbar { + tab("tab 1") { + page { + } + } + tab("tab 2") { + page { + } + } + } + } + val element = document.getElementById("test") + assertEqualsHtml( + "
", + element?.innerHTML, + "Should render Onsen UI tab bar component" + ) + } + } +} \ No newline at end of file diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/BottomToolbarSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/BottomToolbarSpec.kt new file mode 100644 index 00000000..05f7ac0e --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/BottomToolbarSpec.kt @@ -0,0 +1,52 @@ +/* + * 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.onsenui.toolbar + +import pl.treksoft.kvision.html.div +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.toolbar.bottomToolbar +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class BottomToolbarSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + bottomToolbar { + div("toolbar") + } + } + val element = document.getElementById("test") + assertEqualsHtml( + "
toolbar
", + element?.innerHTML, + "Should render Onsen UI bottom toolbar component" + ) + } + } +} \ No newline at end of file diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarButtonSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarButtonSpec.kt new file mode 100644 index 00000000..7c0fd448 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarButtonSpec.kt @@ -0,0 +1,54 @@ +/* + * 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.onsenui.toolbar + +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.toolbar.toolbar +import pl.treksoft.kvision.onsenui.toolbar.toolbarButton +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class ToolbarButtonSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + toolbar("center") { + right { + toolbarButton("test") + } + } + } + val element = document.getElementById("test") + assertEqualsHtml( + "
center
test
", + element?.innerHTML, + "Should render Onsen UI toolbar button component" + ) + } + } +} diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarSpec.kt new file mode 100644 index 00000000..f9a3eac3 --- /dev/null +++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarSpec.kt @@ -0,0 +1,52 @@ +/* + * 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.onsenui.toolbar + +import pl.treksoft.kvision.onsenui.core.page +import pl.treksoft.kvision.onsenui.toolbar.toolbar +import pl.treksoft.kvision.panel.ContainerType +import pl.treksoft.kvision.panel.Root +import test.pl.treksoft.kvision.DomSpec +import kotlin.browser.document +import kotlin.test.Test + +class ToolbarSpec : DomSpec { + + @Test + fun render() { + run { + val root = Root("test", containerType = ContainerType.FIXED) + root.page { + toolbar("center") { + left { +"left" } + right { +"right" } + } + } + val element = document.getElementById("test") + assertEqualsHtml( + "
left
center
right
", + element?.innerHTML, + "Should render Onsen UI toolbar component" + ) + } + } +} \ No newline at end of file -- cgit