aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt17
-rw-r--r--src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt17
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
index 183fa9fa..c68d5e7e 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
@@ -86,4 +86,21 @@ class WidgetSpec : WSpec {
}
}
+ @Test
+ fun getElement() {
+ runW { widget, element ->
+ val e = widget.getElement()
+ assertTrue("Should return correct dom element") { e == element }
+ }
+ }
+
+ @Test
+ fun getElementJQuery() {
+ runW { widget, element ->
+ val j = widget.getElementJQuery()
+ assertTrue("Should return correct jQuery object") { j != null }
+ val e = j?.get()?.get(0)
+ assertTrue("Should return correct dom element from jQuery object") { e == element }
+ }
+ }
} \ No newline at end of file
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 23caf3a7..ec755fbf 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -7,6 +7,7 @@ import test.pl.treksoft.kvision.DomSpec
import kotlin.browser.document
import kotlin.test.Test
import kotlin.test.assertEquals
+import kotlin.test.assertTrue
class DropDownSpec : DomSpec {
@@ -65,4 +66,20 @@ class DropDownSpec : DomSpec {
}
}
+ @Test
+ fun toggle() {
+ run {
+ 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 }
+ dd.toggle()
+ val classes2 = dd.getElementJQuery()?.attr("class")
+ assertTrue("Dropdown is visible after toggle") { classes2?.contains("open") == true }
+ dd.toggle()
+ val classes3 = dd.getElementJQuery()?.attr("class")
+ assertTrue("Dropdown is hidden after second toggle") { classes3?.contains("open") == false }
+ }
+ }
} \ No newline at end of file