Created
July 15, 2012 00:48
-
-
Save bunnymatic/3114142 to your computer and use it in GitHub Desktop.
Jasmine Helpers to fire events with Prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jasmine = jasmine || {} | |
jasmine.getEvents = function(sel, event_name) { | |
var events = []; | |
try { | |
var evs = $$(sel)[0].getStorage().get('prototype_event_registry'); | |
events = evs.get(event_name); | |
} | |
catch(e) {} | |
return events; | |
}; | |
jasmine.triggerEvent = function(sel, event_name) { | |
var events = jasmine.getEvents(sel, event_name); | |
_.each(events, function(ev) { | |
_.each($$(sel), function(el) { | |
ev.apply(el); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment