aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap/src/test/kotlin
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-07 09:58:14 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-07 09:58:14 +0200
commit04ac8542c218b7ce5199350f0880e8f7cb4252b6 (patch)
tree4f96d1c3bb8281289b96e2b11eecc404a3c98788 /kvision-modules/kvision-bootstrap/src/test/kotlin
parent6678eec9799681b09e5ac85de1a39596d56de22f (diff)
parent6b14906f0e35dc522bd1c1a44682d728315cf619 (diff)
downloadkvision-04ac8542c218b7ce5199350f0880e8f7cb4252b6.tar.gz
kvision-04ac8542c218b7ce5199350f0880e8f7cb4252b6.tar.bz2
kvision-04ac8542c218b7ce5199350f0880e8f7cb4252b6.zip
Merge branch 'bs4'
Diffstat (limited to 'kvision-modules/kvision-bootstrap/src/test/kotlin')
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt4
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/ContextMenuSpec.kt76
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt29
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/HeaderSpec.kt46
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/SeparatorSpec.kt46
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt16
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt54
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt54
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt71
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt50
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt117
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt56
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt55
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ButtonGroupSpec.kt56
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ToolbarSpec.kt47
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt11
16 files changed, 756 insertions, 32 deletions
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
index 1ad97acc..fc3d5242 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/TestUtil.kt
@@ -70,8 +70,8 @@ interface DomSpec : TestSpec {
fun assertEqualsHtml(expected: String?, actual: String?, message: String?) {
if (expected != null && actual != null) {
- val exp = jQuery(expected)
- val act = jQuery(actual)
+ val exp = jQuery(expected.replace("position: ;","position: absolute;"))
+ val act = jQuery(actual.replace("position: ;","position: absolute;"))
val result = exp[0]?.isEqualNode(act[0])
if (result == true) {
assertTrue(result == true, message)
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/ContextMenuSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/ContextMenuSpec.kt
new file mode 100644
index 00000000..b467f1ff
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/ContextMenuSpec.kt
@@ -0,0 +1,76 @@
+/*
+ * 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.ContextMenu
+import pl.treksoft.kvision.dropdown.ContextMenu.Companion.setContextMenu
+import pl.treksoft.kvision.html.Link.Companion.link
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.utils.obj
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class ContextMenuSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val m = ContextMenu {
+ link("a", "b")
+ link("c", "d")
+ }
+ root.setContextMenu(m)
+ m.show()
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"dropdown-menu\" style=\"display: block;\"><a href=\"b\">a</a><a href=\"d\">c</a></div>",
+ element?.innerHTML,
+ "Should render correct context menu"
+ )
+ }
+ }
+
+ @Suppress("UnsafeCastFromDynamic")
+ @Test
+ fun positionMenu() {
+ run {
+ val root = Root("test", fixed = true)
+ val m = ContextMenu {
+ link("a", "b")
+ link("c", "d")
+ }
+ root.setContextMenu(m)
+ m.positionMenu(obj {
+ pageX = 40
+ pageY = 50
+ })
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"dropdown-menu\" style=\"display: block; top: 50px; left: 40px;\"><a href=\"b\">a</a><a href=\"d\">c</a></div>",
+ element?.innerHTML,
+ "Should place context menu in the correct position"
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
index af35fa51..f75331f3 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -22,6 +22,7 @@
package test.pl.treksoft.kvision.dropdown
import pl.treksoft.kvision.dropdown.DD
+import pl.treksoft.kvision.dropdown.Direction
import pl.treksoft.kvision.dropdown.DropDown
import pl.treksoft.kvision.panel.Root
import test.pl.treksoft.kvision.DomSpec
@@ -37,11 +38,11 @@ class DropDownSpec : DomSpec {
val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag")
root.add(dd)
- dd.toggle()
+ dd.list.getElementJQueryD()?.dropdown("toggle")
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -52,13 +53,13 @@ class DropDownSpec : DomSpec {
fun renderDropUp() {
run {
val root = Root("test", fixed = true)
- val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag").apply { dropup = true }
+ val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag").apply { direction = Direction.DROPUP }
root.add(dd)
- dd.toggle()
+ dd.list.getElementJQueryD()?.dropdown("toggle")
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropup open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li><a href=\"#!/x\">abc</a></li><li><a href=\"#!/y\">def</a></li></ul></div>",
+ "<div class=\"dropup show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"top-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -71,11 +72,11 @@ class DropDownSpec : DomSpec {
val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.option), "flag")
root.add(dd)
- dd.toggle()
+ dd.list.getElementJQueryD()?.dropdown("toggle")
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"dropdown-header\">abc</li></ul></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><h6 class=\"dropdown-header\">abc</h6></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -88,11 +89,11 @@ class DropDownSpec : DomSpec {
val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.option), "flag")
root.add(dd)
- dd.toggle()
+ dd.list.getElementJQueryD()?.dropdown("toggle")
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"divider\" role=\"separator\"></li></ul></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><div class=\"dropdown-divider\"></div></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -105,11 +106,11 @@ class DropDownSpec : DomSpec {
val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.option), "flag")
root.add(dd)
- dd.toggle()
+ dd.list.getElementJQueryD()?.dropdown("toggle")
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown open\"><button class=\"dropdown btn btn-default\" id=\"$id\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" role=\"button\" href=\"#\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"$id\" aria-expanded=\"true\"><li class=\"disabled\"><a>abc</a></li></ul></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item disabled\" tabindex=\"-1\" aria-disabled=\"true\" href=\"javascript:void(0)\">abc</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -122,10 +123,10 @@ class DropDownSpec : DomSpec {
val root = Root("test", fixed = true)
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag")
root.add(dd)
- val visible = dd.getElementJQuery()?.hasClass("open") ?: false
+ val visible = dd.getElementJQuery()?.hasClass("show") ?: false
assertTrue("Dropdown menu is not visible before toggle") { !visible }
- dd.toggle()
- val visible2 = dd.getElementJQuery()?.hasClass("open") ?: false
+ dd.list.getElementJQueryD()?.dropdown("toggle")
+ val visible2 = dd.getElementJQuery()?.hasClass("show") ?: false
assertTrue("Dropdown menu is visible after toggle") { visible2 }
}
}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/HeaderSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/HeaderSpec.kt
new file mode 100644
index 00000000..25ca7a7d
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/HeaderSpec.kt
@@ -0,0 +1,46 @@
+/*
+ * 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.Header
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class HeaderSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val h = Header("Test")
+ root.add(h)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<h6 class=\"dropdown-header\">Test</h6>",
+ element?.innerHTML,
+ "Should render correct drop down header"
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/SeparatorSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/SeparatorSpec.kt
new file mode 100644
index 00000000..36c22a74
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/SeparatorSpec.kt
@@ -0,0 +1,46 @@
+/*
+ * 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.Separator
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class SeparatorSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val s = Separator()
+ root.add(s)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"dropdown-divider\"></div>",
+ element?.innerHTML,
+ "Should render correct drop down separator"
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
index c3d17de9..48a8b5a0 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/modal/AlertSpec.kt
@@ -37,22 +37,22 @@ class AlertSpec : DomSpec {
fun render() {
run {
Root("test", fixed = true)
- Alert.show("Alert caption", "Alert content")
- val alert = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] }
+ Alert.show("Alert caption", "Alert content", animation = false)
+ val alert = document.getElementById("test")?.let { jQuery(it).parent().parent().find(".modal")[0] }
assertNotNull(alert, "Should show alert window")
- val title = document.getElementById("test")?.let { jQuery(it).find(".modal-title").html() }
+ val title = document.getElementById("test")?.let { jQuery(it).parent().parent().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() }
+ val body = document.getElementById("test")?.let { jQuery(it).parent().parent().find(".modal-body").html() }
assertEquals("<div>Alert content</div>", body, "Should render alert window with correct content")
- val footer = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").html() }
+ val footer = document.getElementById("test")?.let { jQuery(it).parent().parent().find(".modal-footer").html() }
assertEqualsHtml(
- "<button class=\"btn btn-primary\" type=\"button\"><span class=\"glyphicon glyphicon-ok\"></span> OK</button>",
+ "<button class=\"btn btn-primary\" type=\"button\"><i class=\"fas fa-check\"></i> OK</button>",
footer,
"Should render alert window with correct footer"
)
- val button = document.getElementById("test")?.let { jQuery(it).find(".modal-footer").find("button") }
+ val button = document.getElementById("test")?.let { jQuery(it).parent().parent().find(".modal-footer").find("button") }
button?.click()
- val alert2 = document.getElementById("test")?.let { jQuery(it).find(".modal")[0] }
+ val alert2 = document.getElementById("test")?.let { jQuery(it).parent().parent().find(".modal")[0] }
assertNull(alert2, "Should hide alert window after clicking OK")
}
}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt
new file mode 100644
index 00000000..8eb7bd5b
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.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.navbar
+
+import pl.treksoft.kvision.navbar.NavForm
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class NavFormSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val navf = NavForm()
+ root.add(navf)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<form class=\"form-inline\"></form>",
+ element?.innerHTML,
+ "Should render correct nav form"
+ )
+ navf.rightAlign = true
+ assertEqualsHtml(
+ "<form class=\"form-inline ml-auto\"></form>",
+ element?.innerHTML,
+ "Should render correct right aligned nav form"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt
new file mode 100644
index 00000000..2e52557f
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.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.navbar
+
+import pl.treksoft.kvision.navbar.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", fixed = true)
+ val nav = Nav()
+ root.add(nav)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"navbar-nav\"></div>",
+ element?.innerHTML,
+ "Should render correct nav"
+ )
+ nav.rightAlign = true
+ assertEqualsHtml(
+ "<div class=\"navbar-nav ml-auto\"></div>",
+ element?.innerHTML,
+ "Should render correct right aligned nav"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
new file mode 100644
index 00000000..1658e63c
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
@@ -0,0 +1,71 @@
+/*
+ * 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.navbar
+
+import pl.treksoft.kvision.html.Link.Companion.link
+import pl.treksoft.kvision.html.TAG
+import pl.treksoft.kvision.html.Tag.Companion.tag
+import pl.treksoft.kvision.navbar.Nav
+import pl.treksoft.kvision.navbar.Navbar
+import pl.treksoft.kvision.navbar.NavbarColor
+import pl.treksoft.kvision.navbar.NavbarType
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class NavbarSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val navbar = Navbar("TEST", NavbarType.FIXEDTOP)
+ root.add(navbar)
+ val element = document.getElementById("test")
+ val id = navbar.container.id
+ assertEqualsHtml(
+ "<nav class=\"navbar fixed-top navbar-expand-lg navbar-light bg-light\"><a class=\"navbar-brand\" href=\"#\">TEST</a><button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-controls=\"$id\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button><div class=\"collapse navbar-collapse\" id=\"$id\"></div></nav>",
+ element?.innerHTML,
+ "Should render correct navbar"
+ )
+ navbar.nColor = NavbarColor.DARK
+ assertEqualsHtml(
+ "<nav class=\"navbar fixed-top navbar-expand-lg bg-light navbar-dark\"><a class=\"navbar-brand\" href=\"#\">TEST</a><button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-controls=\"$id\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button><div class=\"collapse navbar-collapse\" id=\"$id\"></div></nav>",
+ element?.innerHTML,
+ "Should render correct dark navbar"
+ )
+ navbar.add(Nav {
+ tag(TAG.LI) {
+ link("Test", "#!/test")
+ }
+ })
+ assertEqualsHtml(
+ "<nav class=\"navbar fixed-top navbar-expand-lg bg-light navbar-dark\"><a class=\"navbar-brand\" href=\"#\">TEST</a><button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-controls=\"$id\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button><div class=\"collapse navbar-collapse\" id=\"$id\"><div class=\"navbar-nav\"><li><a href=\"#!/test\">Test</a></li></div></div></nav>",
+ element?.innerHTML,
+ "Should render correct navbar with nav link"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt
new file mode 100644
index 00000000..1ebac202
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/ResponsiveGridPanelSpec.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package test.pl.treksoft.kvision.panel
+
+import pl.treksoft.kvision.html.Span
+import pl.treksoft.kvision.panel.ResponsiveGridPanel
+import pl.treksoft.kvision.panel.Root
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class ResponsiveGridPanelSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val rgPanel = ResponsiveGridPanel()
+ root.add(rgPanel)
+ rgPanel.add(Span("abc"), 1, 1)
+ rgPanel.add(Span("def"), 2, 2)
+ rgPanel.add(Span("ghi"), 3, 3)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"container-fluid\"><div class=\"row\"><div class=\"col-md-4\"><span>abc</span></div><div class=\"col-md-4\"></div><div class=\"col-md-4\"></div></div><div class=\"row\"><div class=\"col-md-4\"></div><div class=\"col-md-4\"><span>def</span></div><div class=\"col-md-4\"></div></div><div class=\"row\"><div class=\"col-md-4\"></div><div class=\"col-md-4\"></div><div class=\"col-md-4\"><span>ghi</span></div></div></div>",
+ element?.innerHTML,
+ "Should render correct responsive grid panel"
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt
new file mode 100644
index 00000000..7a76cde9
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/panel/TabPanelSpec.kt
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package test.pl.treksoft.kvision.panel
+
+import pl.treksoft.jquery.jQuery
+import pl.treksoft.kvision.html.Span
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.panel.TabPanel
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class TabPanelSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val tabs = TabPanel()
+ root.add(tabs)
+ val label1 = Span("abc")
+ val label2 = Span("def")
+ tabs.addTab("ABC", label1)
+ tabs.addTab("DEF", label2)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div><ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a class=\"nav-link active\" href=\"#\">ABC</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#\">DEF</a></li></ul><div><span>abc</span></div></div>",
+ element?.innerHTML,
+ "Should render correct tabs"
+ )
+ }
+ }
+
+ @Test
+ fun setActiveIndex() {
+ run {
+ val root = Root("test", fixed = true)
+ val tabs = TabPanel()
+ root.add(tabs)
+ val label1 = Span("abc")
+ val label2 = Span("def")
+ tabs.addTab("ABC", label1)
+ tabs.addTab("DEF", label2)
+ tabs.activeIndex = 1
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div><ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a class=\"nav-link\" href=\"#\">ABC</a></li><li class=\"nav-item\"><a class=\"nav-link active\" href=\"#\">DEF</a></li></ul><div><span>def</span></div></div>",
+ element?.innerHTML,
+ "Should change selected tab"
+ )
+ }
+ }
+
+ @Test
+ fun removeTab() {
+ run {
+ val root = Root("test", fixed = true)
+ val tabs = TabPanel()
+ root.add(tabs)
+ val label1 = Span("abc")
+ val label2 = Span("def")
+ tabs.addTab("ABC", label1)
+ tabs.addTab("DEF", label2)
+ tabs.activeIndex = 1
+ tabs.removeTab(1)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div><ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a class=\"nav-link active\" href=\"#\">ABC</a></li></ul><div><span>abc</span></div></div>",
+ element?.innerHTML,
+ "Should remove tab"
+ )
+ }
+ }
+
+
+ @Test
+ fun tabClick() {
+ run {
+ val root = Root("test", fixed = true)
+ val tabs = TabPanel()
+ root.add(tabs)
+ val label1 = Span("abc")
+ val label2 = Span("def")
+ tabs.addTab("ABC", label1)
+ tabs.addTab("DEF", label2)
+ tabs.removeTab(0)
+ val label3 = Span("ghi")
+ tabs.addTab("GHI", label3)
+ jQuery("#test a")[1]?.click()
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div><ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a class=\"nav-link\" href=\"#\">DEF</a></li><li class=\"nav-item\"><a class=\"nav-link active\" href=\"#\">GHI</a></li></ul><div><span>ghi</span></div></div>",
+ element?.innerHTML,
+ "Should select correct tab by clicking"
+ )
+ }
+ }
+} \ No newline at end of file
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt
new file mode 100644
index 00000000..2f044987
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressBarSpec.kt
@@ -0,0 +1,56 @@
+/*
+ * 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.progress
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.progress.ProgressBar
+import pl.treksoft.kvision.progress.ProgressBarStyle
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class ProgressBarSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val progressBar =
+ ProgressBar(50, style = ProgressBarStyle.SUCCESS, striped = true, content = "Processing ...")
+ root.add(progressBar)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"progress\"><div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 50%;\">Processing ...</div></div>",
+ element?.innerHTML,
+ "Should render correct progress bar"
+ )
+ progressBar.max = 200
+ assertEqualsHtml(
+ "<div class=\"progress\"><div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"200\" style=\"width: 25%;\">Processing ...</div></div>",
+ element?.innerHTML,
+ "Should render correct progress bar after max value change"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.kt
new file mode 100644
index 00000000..4aa14230
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/progress/ProgressIndicatorSpec.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.progress
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.progress.ProgressBarStyle
+import pl.treksoft.kvision.progress.ProgressIndicator
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class ProgressIndicatorSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val ind = ProgressIndicator(50, style = ProgressBarStyle.SUCCESS, striped = true)
+ root.add(ind)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 50%;\"></div>",
+ element?.innerHTML,
+ "Should render correct progress bar indicator"
+ )
+ ind.max = 200
+ assertEqualsHtml(
+ "<div class=\"progress-bar progress-bar-success progress-bar-striped\" role=\"progressbar\" aria-valuenow=\"50\" aria-valuemin=\"0\" aria-valuemax=\"200\" style=\"width: 25%;\"></div>",
+ element?.innerHTML,
+ "Should render correct progress bar indicator after max value change"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ButtonGroupSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ButtonGroupSpec.kt
new file mode 100644
index 00000000..b3ddbe40
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ButtonGroupSpec.kt
@@ -0,0 +1,56 @@
+/*
+ * 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.toolbar
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.toolbar.ButtonGroup
+import pl.treksoft.kvision.toolbar.ButtonGroupSize
+import test.pl.treksoft.kvision.DomSpec
+import kotlin.browser.document
+import kotlin.test.Test
+
+class ButtonGroupSpec : DomSpec {
+
+ @Test
+ fun render() {
+ run {
+ val root = Root("test", fixed = true)
+ val group = ButtonGroup()
+ root.add(group)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"btn-group\" role=\"group\"></div>",
+ element?.innerHTML,
+ "Should render correct button group"
+ )
+ group.size = ButtonGroupSize.LARGE
+ group.vertical = true
+ assertEqualsHtml(
+ "<div class=\"btn-group-lg btn-group-vertical\" role=\"group\"></div>",
+ element?.innerHTML,
+ "Should render correct button group with large and vertical buttons"
+ )
+
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ToolbarSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ToolbarSpec.kt
new file mode 100644
index 00000000..d41ef05e
--- /dev/null
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/toolbar/ToolbarSpec.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.toolbar
+
+import pl.treksoft.kvision.panel.Root
+import pl.treksoft.kvision.toolbar.Toolbar
+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", fixed = true)
+ val toolbar = Toolbar()
+ root.add(toolbar)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<div class=\"btn-toolbar\" role=\"toolbar\"></div>",
+ element?.innerHTML,
+ "Should render correct toolbar"
+ )
+ }
+ }
+
+}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
index c79b9d32..a65ff7c3 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt
@@ -35,18 +35,13 @@ class WindowSpec : DomSpec {
val root = Root("test", fixed = true)
val window = Window("Window title", isResizable = false)
root.add(window)
+ window.show()
val id = window.id
val element = document.getElementById("test")
assertEqualsHtml(
- "<div class=\"modal-content kv-window\" id=\"$id\" style=\"width: auto; position: absolute; z-index: 901; overflow: hidden;\"><div class=\"modal-header\"><h4 class=\"modal-title\">Window title</h4></div><div style=\"height: auto; overflow: auto;\"></div></div>",
+ "<div class=\"modal-content kv-window\" id=\"$id\" style=\"width: auto; position: absolute; z-index: 901; overflow: hidden;\"><div class=\"modal-header\"><h5 class=\"modal-title\">Window title</h5><div class=\"kv-window-icons-container\"></div></div><div style=\"height: auto; overflow: auto;\"></div></div>",
element?.innerHTML,
- "Should render floating window without resizable handler"
- )
- window.isResizable = true
- assertEqualsHtml(
- "<div class=\"modal-content kv-window\" id=\"$id\" style=\"width: auto; position: absolute; z-index: 901; overflow: hidden; resize: both;\"><div class=\"modal-header\"><h4 class=\"modal-title\">Window title</h4></div><div style=\"height: auto; overflow: auto; margin-bottom: 11px;\"></div><object style=\"position: absolute; top: 0; left: 0; height: 100%; width: 100%; pointer-events: none; z-index: -1; opacity: 0;\" class=\"resize-sensor\" tabindex=\"-1\" type=\"text/html\" data=\"about:blank\"></object></div>",
- element?.innerHTML,
- "Should render floating window with resizable handler"
+ "Should render floating window"
)
}
}