From 2072d1b9c1b9d4f515cc1759b12ca19db7106d82 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 3 Sep 2017 03:34:26 +0200 Subject: DropDown attributes --- .../pl/treksoft/kvision/dropdown/DropDown.kt | 2 +- .../pl/treksoft/kvision/dropdown/DropDownSpec.kt | 34 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index 7176f725..c0a87297 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -23,7 +23,7 @@ open class DropDown(text: String, elements: List, icon: String? = nu when (it.second) { DD.HEADER.POS -> Tag(TAG.LI, it.first, classes = setOf("dropdown-header")) DD.SEPARATOR.POS -> { - val tag = Tag(TAG.LI, classes = setOf("divider")) + val tag = Tag(TAG.LI, it.first, classes = setOf("divider")) tag.role = "separator" tag } diff --git a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt index fec45a47..23caf3a7 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt @@ -1,6 +1,7 @@ package test.pl.treksoft.kvision.dropdown import pl.treksoft.kvision.core.Root +import pl.treksoft.kvision.dropdown.DD import pl.treksoft.kvision.dropdown.DropDown import test.pl.treksoft.kvision.DomSpec import kotlin.browser.document @@ -31,4 +32,37 @@ class DropDownSpec : DomSpec { } } + @Test + fun render_HeaderElement() { + run { + val root = Root("test") + val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.POS), "flag") + root.add(dd) + val element = document.getElementById("test") + assertEquals("
  • abc
", element?.innerHTML, "Should render correct drop down") + } + } + + @Test + fun render_SeparatorElement() { + run { + val root = Root("test") + val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.POS), "flag") + root.add(dd) + val element = document.getElementById("test") + assertEquals("
  • abc
", element?.innerHTML, "Should render correct drop down") + } + } + + @Test + fun render_DisabledElement() { + run { + val root = Root("test") + val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.POS), "flag") + root.add(dd) + val element = document.getElementById("test") + assertEquals("
", element?.innerHTML, "Should render correct drop down") + } + } + } \ No newline at end of file -- cgit