aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt36
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt36
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt52
3 files changed, 124 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt
new file mode 100644
index 00000000..87898964
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+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", true)
+ val navf = NavForm()
+ root.add(navf)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<form class=\"navbar-form navbar-left\"></form>",
+ element?.innerHTML,
+ "Should render correct nav form"
+ )
+ navf.rightAlign = true
+ assertEqualsHtml(
+ "<form class=\"navbar-form navbar-right\"></form>",
+ element?.innerHTML,
+ "Should render correct right aligned nav form"
+ )
+
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt
new file mode 100644
index 00000000..521b8438
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+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", true)
+ val nav = Nav()
+ root.add(nav)
+ val element = document.getElementById("test")
+ assertEqualsHtml(
+ "<ul class=\"nav navbar-nav\"></ul>",
+ element?.innerHTML,
+ "Should render correct nav"
+ )
+ nav.rightAlign = true
+ assertEqualsHtml(
+ "<ul class=\"nav navbar-nav navbar-right\"></ul>",
+ element?.innerHTML,
+ "Should render correct right aligned nav"
+ )
+
+ }
+ }
+
+}
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
new file mode 100644
index 00000000..7da64424
--- /dev/null
+++ b/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2018. Robert Jaros
+ */
+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.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", true)
+ val navbar = Navbar("TEST", NavbarType.FIXEDTOP)
+ root.add(navbar)
+ val element = document.getElementById("test")
+ val id = navbar.container.id
+ assertEqualsHtml(
+ "<nav class=\"navbar navbar-fixed-top navbar-default\"><div class=\"container-fluid\"><div class=\"navbar-header\"><button class=\"navbar-toggle collapsed\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-expanded=\"false\"><span class=\"sr-only\">Toggle navigation</span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span></button><a class=\"navbar-brand\" href=\"#\">TEST</a></div><div class=\"collapse navbar-collapse\" id=\"$id\"></div></div></nav>",
+ element?.innerHTML,
+ "Should render correct navbar"
+ )
+ navbar.inverted = true
+ assertEqualsHtml(
+ "<nav class=\"navbar navbar-fixed-top navbar-inverse\"><div class=\"container-fluid\"><div class=\"navbar-header\"><button class=\"navbar-toggle collapsed\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-expanded=\"false\"><span class=\"sr-only\">Toggle navigation</span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span></button><a class=\"navbar-brand\" href=\"#\">TEST</a></div><div class=\"collapse navbar-collapse\" id=\"$id\"></div></div></nav>",
+ element?.innerHTML,
+ "Should render correct inverted navbar"
+ )
+ navbar.add(Nav {
+ tag(TAG.LI) {
+ link("Test", "#!/test")
+ }
+ })
+ assertEqualsHtml(
+ "<nav class=\"navbar navbar-fixed-top navbar-inverse\"><div class=\"container-fluid\"><div class=\"navbar-header\"><button class=\"navbar-toggle collapsed\" type=\"button\" data-toggle=\"collapse\" data-target=\"#$id\" aria-expanded=\"false\"><span class=\"sr-only\">Toggle navigation</span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span><span class=\"icon-bar\"></span></button><a class=\"navbar-brand\" href=\"#\">TEST</a></div><div class=\"collapse navbar-collapse\" id=\"$id\"><ul class=\"nav navbar-nav\"><li><a href=\"#!/test\">Test</a></li></ul></div></div></nav>",
+ element?.innerHTML,
+ "Should render correct navbar with nav link"
+ )
+
+ }
+ }
+
+}