aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/handler_stack_test.coffee23
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee2
2 files changed, 25 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 }
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index 3258bcd6..7f666068 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -41,6 +41,8 @@ exports.chrome =
addListener: () -> true
getAll: () -> true
+ browserAction:
+ setBadgeBackgroundColor: ->
storage:
# chrome.storage.local
local: