From f76c15c6ae6565c0c08569a127974dfd3383ed88 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 11 Jan 2015 12:19:19 +0000 Subject: Modes; tweaks, including more tests. --- tests/unit_tests/handler_stack_test.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/unit_tests') 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 } -- cgit v1.2.3