From 6f7435b41e8994821649a50978aeb5b5b65951bd Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 16 Sep 2017 15:35:51 +0200 Subject: Fixed dropdown tests --- .../pl/treksoft/kvision/dropdown/DropDownSpec.kt | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/test') 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 ec755fbf..ecf803f4 100644 --- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt +++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt @@ -17,8 +17,9 @@ class DropDownSpec : DomSpec { val root = Root("test") val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag") root.add(dd) + dd.toggle() val element = document.getElementById("test") - assertEquals("
", element?.innerHTML, "Should render correct drop down") + assertEquals("
", element?.innerHTML, "Should render correct drop down") } } @@ -28,8 +29,9 @@ class DropDownSpec : DomSpec { 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") + assertEquals("
", element?.innerHTML, "Should render correct drop down") } } @@ -39,8 +41,9 @@ class DropDownSpec : DomSpec { val root = Root("test") val dd = DropDown("Dropdown", listOf("abc" to DD.HEADER.POS), "flag") root.add(dd) + dd.toggle() val element = document.getElementById("test") - assertEquals("
", element?.innerHTML, "Should render correct drop down") + assertEquals("
", element?.innerHTML, "Should render correct drop down") } } @@ -50,8 +53,9 @@ class DropDownSpec : DomSpec { val root = Root("test") val dd = DropDown("Dropdown", listOf("abc" to DD.SEPARATOR.POS), "flag") root.add(dd) + dd.toggle() val element = document.getElementById("test") - assertEquals("
", element?.innerHTML, "Should render correct drop down") + assertEquals("
", element?.innerHTML, "Should render correct drop down") } } @@ -61,8 +65,9 @@ class DropDownSpec : DomSpec { val root = Root("test") val dd = DropDown("Dropdown", listOf("abc" to DD.DISABLED.POS), "flag") root.add(dd) + dd.toggle() val element = document.getElementById("test") - assertEquals("
", element?.innerHTML, "Should render correct drop down") + assertEquals("
", element?.innerHTML, "Should render correct drop down") } } @@ -72,14 +77,16 @@ class DropDownSpec : DomSpec { val root = Root("test") val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag") root.add(dd) - val classes = dd.getElementJQuery()?.attr("class") - assertTrue("Dropdown is hidden before toggle") { classes?.contains("open") == false } + val menu = dd.list.getElementJQuery() + assertTrue("Dropdown menu is not rendered before toggle") { menu == null } dd.toggle() - val classes2 = dd.getElementJQuery()?.attr("class") - assertTrue("Dropdown is visible after toggle") { classes2?.contains("open") == true } + 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 } dd.toggle() - val classes3 = dd.getElementJQuery()?.attr("class") - assertTrue("Dropdown is hidden after second toggle") { classes3?.contains("open") == false } + val menu3 = dd.list.getElementJQuery() + assertTrue("Dropdown menu is not rendered after second toggle") { menu3 == null } } } } \ No newline at end of file -- cgit