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
1 files changed, 15 insertions, 2 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 42a07ba8..159df178 100644
--- a/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
+++ b/src/test/kotlin/test/pl/treksoft/kvision/core/WidgetSpec.kt
@@ -96,16 +96,29 @@ class WidgetSpec : WSpec {
fun setEventListener() {
runW { widget, _ ->
widget.setEventListener<Widget> { click = { } }
- assertTrue("Element should have an event listener") { widget.listenersMap.size == 1 }
+ assertTrue("Element should have one event listener") { widget.listenersMap["click"]?.size == 1 }
+ widget.setEventListener<Widget> { click = { } }
+ assertTrue("Element should have two event listeners") { widget.listenersMap["click"]?.size == 2 }
}
}
@Test
fun removeEventListener() {
runW { widget, _ ->
+ val id = widget.setEventListener<Widget> { click = { } }
+ widget.setEventListener<Widget> { click = { } }
+ widget.removeEventListener(id)
+ assertTrue("One of event listeners is removed") { widget.listenersMap["click"]?.size == 1 }
+ }
+ }
+
+ @Test
+ fun removeEventListeners() {
+ runW { widget, _ ->
+ widget.setEventListener<Widget> { click = { } }
widget.setEventListener<Widget> { click = { } }
widget.removeEventListeners()
- assertTrue("Element should not have any event listener") { widget.listenersMap.size == 0 }
+ assertTrue("Element should not have any event listeners") { widget.listenersMap.isEmpty() }
}
}