aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-onsenui/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-06-07 23:17:31 +0200
committerRobert Jaros <rjaros@finn.pl>2020-06-07 23:17:31 +0200
commitc2716ef0aae16553655cab4ea24f685e49e5fee8 (patch)
tree0a3fc4a4603e0cfa1faea3a3ca9d6673b4b9cbb0 /kvision-modules/kvision-onsenui/src
parent353815977be03d462393c57b829f2264aa9be85d (diff)
downloadkvision-c2716ef0aae16553655cab4ea24f685e49e5fee8.tar.gz
kvision-c2716ef0aae16553655cab4ea24f685e49e5fee8.tar.bz2
kvision-c2716ef0aae16553655cab4ea24f685e49e5fee8.zip
OnsenUI carousel component. Basic tests for OnsenUI module (#126)HEADmaster
Diffstat (limited to 'kvision-modules/kvision-onsenui/src')
-rw-r--r--kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/Carousel.kt348
-rw-r--r--kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/CarouselItem.kt87
-rw-r--r--kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/core/Page.kt4
-rw-r--r--kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/tabbar/Tabbar.kt8
-rw-r--r--kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/toolbar/Toolbar.kt2
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/OnsenUISpec.kt40
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselItemSpec.kt54
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/carousel/CarouselSpec.kt51
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/BackButtonSpec.kt55
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/NavigatorSpec.kt51
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/PageSpec.kt48
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/splitter/SplitterSpec.kt62
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/tabbar/TabbarSpec.kt59
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/BottomToolbarSpec.kt52
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarButtonSpec.kt54
-rw-r--r--kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/toolbar/ToolbarSpec.kt52
16 files changed, 1020 insertions, 7 deletions
diff --git a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/Carousel.kt b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/Carousel.kt
new file mode 100644
index 00000000..5998eba5
--- /dev/null
+++ b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/Carousel.kt
@@ -0,0 +1,348 @@
+/*
+ * 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 pl.treksoft.kvision.onsenui.carousel
+
+import com.github.snabbdom.VNode
+import pl.treksoft.kvision.core.Component
+import pl.treksoft.kvision.core.Container
+import pl.treksoft.kvision.core.CssSize
+import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.panel.SimplePanel
+import pl.treksoft.kvision.utils.asString
+import pl.treksoft.kvision.utils.obj
+import pl.treksoft.kvision.utils.set
+import kotlin.js.Promise
+
+enum class CarouselDirection(internal val type: String) {
+ HORIZONTAL("horizontal"),
+ VERTICAL("vertical")
+}
+
+/**
+ * A carousel component.
+ *
+ * @constructor Creates a carousel component.
+ * @param direction a carousel direction
+ * @param fullscreen whether the carousel should fill the whole screen
+ * @param overscrollable whether the carousel should scroll past first and last items
+ * @param animation determines if the transitions are animated
+ * @param swipeable determines if the carousel can be scrolled by drag or swipe
+ * @param classes a set of CSS class names
+ * @param init an initializer extension function
+ */
+open class Carousel(
+ direction: CarouselDirection? = null,
+ fullscreen: Boolean? = null,
+ overscrollable: Boolean? = null,
+ animation: Boolean? = null,
+ swipeable: Boolean? = null,
+ initialIndex: Int? = null,
+ classes: Set<String> = setOf(),
+ init: (Carousel.() -> Unit)? = null
+) : SimplePanel(classes) {
+
+ /**
+ * A carousel direction.
+ */
+ var direction: CarouselDirection? by refreshOnUpdate(direction)
+
+ /**
+ * Whether the carousel should fill the whole screen.
+ */
+ var fullscreen: Boolean? by refreshOnUpdate(fullscreen)
+
+ /**
+ * Whether the carousel should scroll past first and last items.
+ */
+ var overscrollable: Boolean? by refreshOnUpdate(overscrollable)
+
+ /**
+ * Determines if the transitions are animated.
+ */
+ var animation: Boolean? by refreshOnUpdate(animation)
+
+ /**
+ * Determines if the carousel can be scrolled by drag or swipe.
+ */
+ var swipeable: Boolean? by refreshOnUpdate(swipeable)
+
+ /**
+ * The index of the item to show on start.
+ */
+ var initialIndex: Int? by refreshOnUpdate(initialIndex)
+
+ /**
+ * Whether the selected item will be in the center of the carousel instead of the beginning.
+ */
+ var centered: Boolean? by refreshOnUpdate()
+
+ /**
+ * The item width (only for horizontal direction).
+ */
+ var itemWidth: CssSize? by refreshOnUpdate()
+
+ /**
+ * The item height (only for vertical direction).
+ */
+ var itemHeight: CssSize? by refreshOnUpdate()
+
+ /**
+ * Whether the carousel will be automatically scrolled to the closest item border.
+ */
+ var autoScroll: Boolean? by refreshOnUpdate()
+
+ /**
+ * Specifies how much the user must drag the carousel in order for it to auto scroll to the next item.
+ */
+ var autoScrollRatio: Number? by refreshOnUpdate()
+
+ /**
+ * Whether the carousel is disabled.
+ */
+ var disabled: Boolean? by refreshOnUpdate()
+
+ /**
+ * Whether the carousel will automatically refresh when the number of child nodes change.
+ */
+ var autoRefresh: Boolean? by refreshOnUpdate()
+
+ /**
+ * The swiper inner container.
+ */
+ val swiperPanel = SimplePanel(setOf("ons-swiper-target"))
+
+ init {
+ swiperPanel.parent = this
+ @Suppress("LeakingThis")
+ init?.invoke(this)
+ }
+
+ /**
+ * A dynamic property returning the number of carousel items.
+ */
+ val itemCount: dynamic
+ get() = getElement()?.asDynamic()?.itemCount
+
+ /**
+ * Swipe event listener function.
+ */
+ protected var onSwipeCallback: ((Number) -> Unit)? = null
+
+ override fun render(): VNode {
+ return render("ons-carousel", arrayOf(swiperPanel.renderVNode()))
+ }
+
+ @Suppress("UnsafeCastFromDynamic")
+ override fun afterInsert(node: VNode) {
+ if (onSwipeCallback != null) {
+ getElement()?.asDynamic()?.onSwipe = onSwipeCallback
+ }
+ this.getElementJQuery()?.on("postchange") { e, _ ->
+ this.dispatchEvent("onsPostchange", obj { detail = e })
+ }
+ this.getElementJQuery()?.on("refresh") { e, _ ->
+ this.dispatchEvent("onsRefresh", obj { detail = e })
+ }
+ this.getElementJQuery()?.on("overscroll") { e, _ ->
+ this.dispatchEvent("onsOverscroll", obj { detail = e })
+ }
+ }
+
+ override fun getSnAttrs(): List<StringPair> {
+ val sn = super.getSnAttrs().toMutableList()
+ direction?.let {
+ sn.add("direction" to it.type)
+ }
+ if (fullscreen == true) {
+ sn.add("fullscreen" to "fullscreen")
+ }
+ if (overscrollable == true) {
+ sn.add("overscrollable" to "overscrollable")
+ }
+ if (animation == false) {
+ sn.add("animation" to "none")
+ }
+ if (swipeable == true) {
+ sn.add("swipeable" to "swipeable")
+ }
+ initialIndex?.let {
+ sn.add("initial-index" to it.toString())
+ }
+ if (centered == true) {
+ sn.add("centered" to "centered")
+ }
+ itemWidth?.let {
+ sn.add("item-width" to it.asString())
+ }
+ itemHeight?.let {
+ sn.add("item-height" to it.asString())
+ }
+ if (autoScroll == true) {
+ sn.add("auto-scroll" to "auto-scroll")
+ }
+ autoScrollRatio?.let {
+ sn.add("auto-scroll-ratio" to it.toString())
+ }
+ if (disabled == true) {
+ sn.add("disabled" to "disabled")
+ }
+ if (autoRefresh == true) {
+ sn.add("auto-refresh" to "auto-refresh")
+ }
+ return sn
+ }
+
+ override fun add(child: Component): SimplePanel {
+ swiperPanel.add(child)
+ return this
+ }
+
+ override fun addAll(children: List<Component>): SimplePanel {
+ swiperPanel.addAll(children)
+ return this
+ }
+
+ override fun remove(child: Component): SimplePanel {
+ swiperPanel.remove(child)
+ return this
+ }
+
+ override fun removeAll(): SimplePanel {
+ swiperPanel.removeAll()
+ return this
+ }
+
+ override fun getChildren(): List<Component> {
+ return swiperPanel.getChildren()
+ }
+
+ /**
+ * Shows specified carousel item.
+ * @param index the carousel item index
+ * @param options a parameter object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun setActiveIndex(index: Int, options: dynamic = undefined): Promise<Unit>? {
+ return getElement()?.asDynamic()?.setActiveIndex(index, options)
+ }
+
+ /**
+ * Gets the active item index.
+ * @return active item index
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun getActiveIndex(): Number {
+ return getElement()?.asDynamic()?.getActiveIndex() ?: -1
+ }
+
+ /**
+ * Shows next carousel item.
+ * @param options a parameter object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun next(options: dynamic = undefined): Promise<Unit> {
+ return getElement()?.asDynamic()?.next(options)
+ }
+
+ /**
+ * Shows previous carousel item.
+ * @param options a parameter object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun prev(options: dynamic = undefined): Promise<Unit> {
+ return getElement()?.asDynamic()?.prev(options)
+ }
+
+ /**
+ * Shows first carousel item.
+ * @param options a parameter object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun first(options: dynamic = undefined): Promise<Unit> {
+ return getElement()?.asDynamic()?.first(options)
+ }
+
+ /**
+ * Shows last carousel item.
+ * @param options a parameter object
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun last(options: dynamic = undefined): Promise<Unit> {
+ return getElement()?.asDynamic()?.last(options)
+ }
+
+ /**
+ * Updates the layout of the carousel.
+ */
+ @Suppress("UnsafeCastFromDynamic")
+ open fun refreshCarousel() {
+ getElement()?.asDynamic()?.refresh()
+ }
+
+ /**
+ * Sets swipe event listener.
+ * @param callback an event listener
+ */
+ open fun onSwipe(callback: (ratio: Number) -> Unit) {
+ onSwipeCallback = callback
+ getElement()?.asDynamic()?.onSwipe = callback
+ }
+
+ /**
+ * Clears swipe event listener.
+ */
+ open fun onSwipeClear() {
+ onSwipeCallback = null
+ getElement()?.asDynamic()?.onSwipe = undefined
+ }
+}
+
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.carousel(
+ direction: CarouselDirection? = null,
+ fullscreen: Boolean? = null,
+ overscrollable: Boolean? = null,
+ animation: Boolean? = null,
+ swipeable: Boolean? = null,
+ initialIndex: Int? = null,
+ classes: Set<String>? = null,
+ className: String? = null,
+ init: (Carousel.() -> Unit)? = null
+): Carousel {
+ val carousel = Carousel(
+ direction,
+ fullscreen,
+ overscrollable,
+ animation,
+ swipeable,
+ initialIndex,
+ classes ?: className.set,
+ init
+ )
+ this.add(carousel)
+ return carousel
+}
diff --git a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/CarouselItem.kt b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/CarouselItem.kt
new file mode 100644
index 00000000..5f1a2803
--- /dev/null
+++ b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/carousel/CarouselItem.kt
@@ -0,0 +1,87 @@
+/*
+ * 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 pl.treksoft.kvision.onsenui.carousel
+
+import com.github.snabbdom.VNode
+import org.w3c.dom.events.MouseEvent
+import pl.treksoft.kvision.html.Align
+import pl.treksoft.kvision.html.Div
+import pl.treksoft.kvision.utils.set
+
+/**
+ * A carousel item component.
+ *
+ * @constructor Creates a carousel item component.
+ * @param content the content of the button.
+ * @param rich whether [content] can contain HTML code
+ * @param align text align
+ * @param classes a set of CSS class names
+ * @param init an initializer extension function
+ */
+open class CarouselItem(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String> = setOf(),
+ init: (CarouselItem.() -> Unit)? = null
+) : Div(content, rich, align, classes) {
+
+ init {
+ @Suppress("LeakingThis")
+ init?.invoke(this)
+ }
+
+ override fun render(elementName: String, children: Array<dynamic>): VNode {
+ return super.render("ons-carousel-item", children)
+ }
+
+ /**
+ * A convenient helper for easy setting onClick event handler.
+ */
+ open fun onClick(handler: CarouselItem.(MouseEvent) -> Unit): CarouselItem {
+ this.setEventListener<CarouselItem> {
+ click = { e ->
+ self.handler(e)
+ }
+ }
+ return this
+ }
+}
+
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Carousel.carouselItem(
+ content: String? = null,
+ rich: Boolean = false,
+ align: Align? = null,
+ classes: Set<String>? = null,
+ className: String? = null,
+ init: (CarouselItem.() -> Unit)? = null
+): CarouselItem {
+ val carouselItem = CarouselItem(content, rich, align, classes ?: className.set, init)
+ this.add(carouselItem)
+ return carouselItem
+}
diff --git a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/core/Page.kt b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/core/Page.kt
index 72ce513a..3b76ed61 100644
--- a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/core/Page.kt
+++ b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/core/Page.kt
@@ -51,7 +51,7 @@ open class Page(classes: Set<String> = setOf(), init: (Page.() -> Unit)? = null)
/**
* The page toolbar.
*/
- var toolbar: Toolbar? = null
+ var toolbarPanel: Toolbar? = null
set(value) {
field = value
value?.parent = this
@@ -101,7 +101,7 @@ open class Page(classes: Set<String> = setOf(), init: (Page.() -> Unit)? = null)
}
override fun render(): VNode {
- val toolbarArr = toolbar?.let { arrayOf(it.renderVNode()) } ?: emptyArray()
+ val toolbarArr = toolbarPanel?.let { arrayOf(it.renderVNode()) } ?: emptyArray()
return render(
"ons-page",
toolbarArr + arrayOf(backgroundPanel.renderVNode(), contentPanel.renderVNode(), fixedPanel.renderVNode())
diff --git a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/tabbar/Tabbar.kt b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/tabbar/Tabbar.kt
index f526676c..a8fd5743 100644
--- a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/tabbar/Tabbar.kt
+++ b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/tabbar/Tabbar.kt
@@ -52,7 +52,7 @@ enum class TabsPosition(internal val type: String) {
*/
open class Tabbar(
tabPosition: TabsPosition? = null,
- animation: Boolean = true,
+ animation: Boolean? = null,
swipeable: Boolean? = null,
classes: Set<String> = setOf(),
init: (Tabbar.() -> Unit)? = null
@@ -66,7 +66,7 @@ open class Tabbar(
/**
* Determines if the transitions are animated.
*/
- var animation: Boolean by refreshOnUpdate(animation)
+ var animation: Boolean? by refreshOnUpdate(animation)
/**
* Determines if the tab bar can be scrolled by drag or swipe.
@@ -123,7 +123,7 @@ open class Tabbar(
tabPosition?.let {
sn.add("position" to it.type)
}
- if (!animation) {
+ if (animation == false) {
sn.add("animation" to "none")
}
if (swipeable == true) {
@@ -208,7 +208,7 @@ open class Tabbar(
}
/**
- * Get the active tab index.
+ * Gets the active tab index.
* @return active tab index
*/
@Suppress("UnsafeCastFromDynamic")
diff --git a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/toolbar/Toolbar.kt b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/toolbar/Toolbar.kt
index f52e110d..49231322 100644
--- a/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/toolbar/Toolbar.kt
+++ b/kvision-modules/kvision-onsenui/src/main/kotlin/pl/treksoft/kvision/onsenui/toolbar/Toolbar.kt
@@ -167,6 +167,6 @@ fun Page.toolbar(
init: (Toolbar.() -> Unit)? = null
): Toolbar {
val toolbar = Toolbar(label, inline, static, classes ?: className.set, init)
- this.toolbar = toolbar
+ this.toolbarPanel = toolbar
return toolbar
}
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(
+ "<ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"><ons-carousel class=\"ons-swiper\" style=\"touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><div class=\"ons-swiper-target\" style=\"transform: translate3d(0px, 0px, 0px);\"><ons-carousel-item style=\"width: 100%;\">item 1</ons-carousel-item><ons-carousel-item style=\"width: 100%;\">item 2</ons-carousel-item></div><div class=\"ons-swiper-blocker\"></div></ons-carousel></div><span></span></ons-page>",
+ 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(
+ "<ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"><ons-carousel class=\"ons-swiper\" style=\"touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><div class=\"ons-swiper-target\" style=\"transform: translate3d(0px, 0px, 0px);\"></div><div class=\"ons-swiper-blocker\"></div></ons-carousel></div><span></span></ons-page>",
+ 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(
+ "<ons-page class=\"page\"><ons-toolbar><div class=\"left toolbar__left\"><ons-back-button></ons-back-button></div><div class=\"center toolbar__center\"></div><div class=\"right toolbar__right\"></div></ons-toolbar><div class=\"page__background\"></div><div class=\"page__content\"></div><span></span></ons-page>",
+ 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("<ons-navigator") == true,
+ "Should render Onsen UI navigator component"
+ )
+ }
+ }
+}
diff --git a/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/PageSpec.kt b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/PageSpec.kt
new file mode 100644
index 00000000..4846ddae
--- /dev/null
+++ b/kvision-modules/kvision-onsenui/src/test/kotlin/test/pl/treksoft/kvision/onsenui/core/PageSpec.kt
@@ -0,0 +1,48 @@
+/*
+ * 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.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 PageSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", containerType = ContainerType.FIXED)
+ root.page {
+ }
+
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"></div><span></span></ons-page>",
+ 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(
+ "<ons-splitter data-device-back-button-handler-id=\"2\" style=\"touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><ons-splitter-side side=\"left\" mode=\"split\" style=\"width: 80%;\"><ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"><div>menu</div></div><span></span></ons-page></ons-splitter-side><ons-splitter-content style=\"left: 80%;\"><ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"><div>content</div></div><span></span></ons-page></ons-splitter-content><ons-splitter-mask style=\"display: none;\"></ons-splitter-mask></ons-splitter>",
+ 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(
+ "<ons-page class=\"page page--wrapper\"><div class=\"page__background\"></div><div class=\"page__content\" style=\"\"><ons-tabbar><div class=\"tabbar__content ons-tabbar__content ons-swiper\" style=\"touch-action: pan-y; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><div class=\"ons-swiper-target\" style=\"transform: translate3d(0px, 0px, 0px);\"></div><div class=\"ons-swiper-blocker\"></div></div><div class=\"tabbar ons-tabbar__footer ons-swiper-tabbar\"><ons-tab page=\"kv_ons_tab_0\" label=\"tab 1\" active=\"\"></ons-tab><ons-tab page=\"kv_ons_tab_1\" label=\"tab 2\"></ons-tab><div class=\"tabbar__border\"></div></div></ons-tabbar></div><span></span></ons-page>",
+ 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(
+ "<ons-page class=\"page\"><div class=\"page__background\"></div><div class=\"page__content\"><ons-bottom-toolbar class=\"bottom-bar\"><div>toolbar</div></ons-bottom-toolbar></div><span></span></ons-page>",
+ 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(
+ "<ons-page class=\"page\"><ons-toolbar><div class=\"left toolbar__left\"></div><div class=\"center toolbar__center\">center</div><div class=\"right toolbar__right\"><ons-toolbar-button>test</ons-toolbar-button></div></ons-toolbar><div class=\"page__background\"></div><div class=\"page__content\"></div><span></span></ons-page>",
+ 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(
+ "<ons-page class=\"page\"><ons-toolbar><div class=\"left toolbar__left\">left</div><div class=\"center toolbar__center\">center</div><div class=\"right toolbar__right\">right</div></ons-toolbar><div class=\"page__background\"></div><div class=\"page__content\"></div><span></span></ons-page>",
+ element?.innerHTML,
+ "Should render Onsen UI toolbar component"
+ )
+ }
+ }
+} \ No newline at end of file