From 2cdc2a42fbbbd4ebd80a219bdc1c7226fa614661 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 22 Mar 2018 13:13:56 +0100 Subject: Unit tests for Navbar --- .../test/pl/treksoft/kvision/navbar/NavFormSpec.kt | 36 +++++++++++++++ .../test/pl/treksoft/kvision/navbar/NavSpec.kt | 36 +++++++++++++++ .../test/pl/treksoft/kvision/navbar/NavbarSpec.kt | 52 ++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/navbar/NavFormSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/navbar/NavSpec.kt create mode 100644 src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt (limited to 'src/test/kotlin') 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( + "
", + element?.innerHTML, + "Should render correct nav form" + ) + navf.rightAlign = true + assertEqualsHtml( + "
", + 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( + "", + element?.innerHTML, + "Should render correct nav" + ) + nav.rightAlign = true + assertEqualsHtml( + "", + 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( + "", + element?.innerHTML, + "Should render correct navbar" + ) + navbar.inverted = true + assertEqualsHtml( + "", + element?.innerHTML, + "Should render correct inverted navbar" + ) + navbar.add(Nav { + tag(TAG.LI) { + link("Test", "#!/test") + } + }) + assertEqualsHtml( + "", + element?.innerHTML, + "Should render correct navbar with nav link" + ) + + } + } + +} -- cgit