diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-22 13:13:56 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-22 13:13:56 +0100 |
commit | 2cdc2a42fbbbd4ebd80a219bdc1c7226fa614661 (patch) | |
tree | 9025d9f15d8ca12fdb3c111e84972539bed95398 /src/test/kotlin | |
parent | 6b77ea5c82d0806cc697e9a269f9f64fbff96273 (diff) | |
download | kvision-2cdc2a42fbbbd4ebd80a219bdc1c7226fa614661.tar.gz kvision-2cdc2a42fbbbd4ebd80a219bdc1c7226fa614661.tar.bz2 kvision-2cdc2a42fbbbd4ebd80a219bdc1c7226fa614661.zip |
Unit tests for Navbar
Diffstat (limited to 'src/test/kotlin')
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" + ) + + } + } + +} |