aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/util_events_spec.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/util_events_spec.lua b/spec/util_events_spec.lua
index 82b30311..fee60f8f 100644
--- a/spec/util_events_spec.lua
+++ b/spec/util_events_spec.lua
@@ -113,6 +113,12 @@ describe("util.events", function ()
pending("should support adding handlers within an event handler")
pending("should support removing handlers within an event handler")
+ it("should support getting the current handlers for an event", function ()
+ e.add_handler("myevent", h);
+ local handlers = e.get_handlers("myevent");
+ assert.equal(h, handlers[1]);
+ end);
+
describe("wrappers", function ()
local w
before_each(function ()
@@ -156,6 +162,21 @@ describe("util.events", function ()
assert.spy(w2).was_called(2);
assert.spy(h).was_called(2);
end);
+
+ it("should support a mix of global and event wrappers", function ()
+ local w2 = spy.new(function (handlers, event_name, event_data)
+ return handlers(event_name, event_data);
+ end);
+ e.add_wrapper(false, w);
+ e.add_handler("myevent", h);
+ e.add_wrapper("myevent", w2);
+ e.fire_event("myevent", "abc");
+ e.remove_wrapper(false, w);
+ e.fire_event("myevent", "abc");
+ assert.spy(w).was_called(1);
+ assert.spy(w2).was_called(2);
+ assert.spy(h).was_called(2);
+ end);
end);
describe("global wrappers", function ()