aboutsummaryrefslogtreecommitdiff
path: root/js/tests/ElggEventsTest.js
blob: cc30e841861447c6372fa57839763f18656ceb85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
ElggEventsTest = TestCase("ElggEventsTest");

ElggEventsTest.prototype.setUp = function() {
	elgg.config.events = {};
	elgg.provide('elgg.config.events.all.all');
};

ElggEventsTest.prototype.testEventHandlersMustBeFunctions = function() {
	assertException(function() { elgg.register_event_handler('str', 'str', 'oops'); });
};

ElggEventsTest.prototype.testReturnValueDefaultsToTrue = function() {
	assertTrue(elgg.trigger_event('fee', 'fum'));
	
	elgg.register_event_handler('fee', 'fum', function() {});
	assertTrue(elgg.trigger_event('fee', 'fum'));
};

ElggEventsTest.prototype.testCanGlomEventsWithAll = function() {
	elgg.register_event_handler('all', 'bar', function() { throw new Error(); });
	assertException("all,bar", function() { elgg.trigger_event('foo', 'bar'); });
	
	elgg.register_event_handler('foo', 'all', function() { throw new Error(); });
	assertException("foo,all", function() { elgg.trigger_event('foo', 'baz'); });
	
	elgg.register_event_handler('all', 'all', function() { throw new Error(); });	
	assertException("all,all", function() { elgg.trigger_event('pinky', 'winky'); });
};