diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-03 03:34:26 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-03 03:34:26 +0200 |
commit | 2072d1b9c1b9d4f515cc1759b12ca19db7106d82 (patch) | |
tree | 8c5ce16b9802d39ea99ee5f7f31f3198201344e2 | |
parent | 70bc6412e0b54119d3f0b6a82c1def78a9088d16 (diff) | |
download | kvision-2072d1b9c1b9d4f515cc1759b12ca19db7106d82.tar.gz kvision-2072d1b9c1b9d4f515cc1759b12ca19db7106d82.tar.bz2 kvision-2072d1b9c1b9d4f515cc1759b12ca19db7106d82.zip |
DropDown attributes
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt | 2 | ||||
-rw-r--r-- | src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt | 34 |
2 files changed, 35 insertions, 1 deletions
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<StringPair>, 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("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_2\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"kv_dropdown_2\"><li class=\"dropdown-header\">abc</li></ul></div>", 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("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_3\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"kv_dropdown_3\"><li class=\"divider\" role=\"separator\">abc</li></ul></div>", 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("<div class=\"dropdown\"><button class=\"dropdown btn btn-default\" id=\"kv_dropdown_4\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"glyphicon glyphicon-flag\"></span> Dropdown</button><ul class=\"dropdown-menu\" aria-labelledby=\"kv_dropdown_4\"><li class=\"disabled\"><a href=\"#\">abc</a></li></ul></div>", element?.innerHTML, "Should render correct drop down") + } + } + }
\ No newline at end of file |