aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-09-09 22:17:34 +0200
committerRobert Jaros <rjaros@finn.pl>2017-09-09 22:17:34 +0200
commit037c9c22bfe23064b2e110225261a26247649967 (patch)
tree53ab791f98500a9921372c027cef6db02c48aff5 /src/test
parent85b48891c61c604c952c8739b50bdae2998c44a7 (diff)
downloadkvision-037c9c22bfe23064b2e110225261a26247649967.tar.gz
kvision-037c9c22bfe23064b2e110225261a26247649967.tar.bz2
kvision-037c9c22bfe23064b2e110225261a26247649967.zip
Integrate jQuery mappings
Globally disabled Data API Added support for dropdown events
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