aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests/handler_stack_test.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-11 12:19:19 +0000
committerStephen Blott2015-01-11 14:36:33 +0000
commitf76c15c6ae6565c0c08569a127974dfd3383ed88 (patch)
tree945c8405da0ce0ddec6d47cd2e3ce60b6d2698ad /tests/unit_tests/handler_stack_test.coffee
parenta8096d235eae39d309c0ffd74e0d2493ff12dd22 (diff)
downloadvimium-f76c15c6ae6565c0c08569a127974dfd3383ed88.tar.bz2
Modes; tweaks, including more tests.
Diffstat (limited to 'tests/unit_tests/handler_stack_test.coffee')
-rw-r--r--tests/unit_tests/handler_stack_test.coffee23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit_tests/handler_stack_test.coffee b/tests/unit_tests/handler_stack_test.coffee
index 0ed8f4c0..0ed85e63 100644
--- a/tests/unit_tests/handler_stack_test.coffee
+++ b/tests/unit_tests/handler_stack_test.coffee
@@ -23,6 +23,29 @@ context "handlerStack",
assert.isTrue @handler2Called
assert.isFalse @handler1Called
+ should "terminate bubbling on stopBubblingAndTrue, and be true", ->
+ @handlerStack.push { keydown: => @handler1Called = true }
+ @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndTrue }
+ assert.isTrue @handlerStack.bubbleEvent 'keydown', {}
+ assert.isTrue @handler2Called
+ assert.isFalse @handler1Called
+
+ should "terminate bubbling on stopBubblingAndTrue, and be false", ->
+ @handlerStack.push { keydown: => @handler1Called = true }
+ @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndFalse }
+ assert.isFalse @handlerStack.bubbleEvent 'keydown', {}
+ assert.isTrue @handler2Called
+ assert.isFalse @handler1Called
+
+ should "restart bubbling on restartBubbling", ->
+ @handler1Called = 0
+ @handler2Called = 0
+ id = @handlerStack.push { keydown: => @handler1Called++; @handlerStack.remove(id); @handlerStack.restartBubbling }
+ @handlerStack.push { keydown: => @handler2Called++; true }
+ assert.isTrue @handlerStack.bubbleEvent 'keydown', {}
+ assert.isTrue @handler1Called == 1
+ assert.isTrue @handler2Called == 2
+
should "remove handlers correctly", ->
@handlerStack.push { keydown: => @handler1Called = true }
handlerId = @handlerStack.push { keydown: => @handler2Called = true }