", element?.innerHTML, "Should render correct drop down")
}
}
@Test
fun render_DropUp() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag", dropup = true)
root.add(dd)
dd.toggle()
val element = document.getElementById("test")
assertEquals("
", element?.innerHTML, "Should render correct drop down")
}
}
@Test
fun render_HeaderElement() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.type), "flag")
root.add(dd)
dd.toggle()
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.type), "flag")
root.add(dd)
dd.toggle()
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.type), "flag")
root.add(dd)
dd.toggle()
val element = document.getElementById("test")
assertEquals("
", element?.innerHTML, "Should render correct drop down")
}
}
@Test
fun toggle() {
run {
val root = Root("test")
val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag")
root.add(dd)
val menu = dd.list.getElementJQuery()
assertTrue("Dropdown menu is not rendered before toggle") { menu == null }
dd.toggle()
val classes = dd.getElementJQuery()?.attr("class")
assertTrue("Dropdown is visible after toggle") { classes?.contains("open") == true }
val menu2 = dd.list.getElementJQuery()
assertTrue("Dropdown menu is rendered after toggle") { menu2 != null }
}
}
}