OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 module("Filter notifier", {setup: prepareFilterComponents, teardown: restoreFi
lterComponents}); | 3 module("Filter notifier", {setup: prepareFilterComponents, teardown: restoreFi
lterComponents}); |
4 | 4 |
5 let triggeredListeners = []; | 5 let triggeredListeners = []; |
6 let listeners = [ | 6 let listeners = [ |
7 function(action, item) triggeredListeners.push(["listener1", action, item]), | 7 function(action, item) triggeredListeners.push(["listener1", action, item]), |
8 function(action, item) triggeredListeners.push(["listener2", action, item]), | 8 function(action, item) triggeredListeners.push(["listener2", action, item]), |
9 function(action, item) triggeredListeners.push(["listener3", action, item]) | 9 function(action, item) triggeredListeners.push(["listener3", action, item]) |
10 ]; | 10 ]; |
11 | 11 |
12 function compareListeners(test, list) | 12 function compareListeners(test, list) |
13 { | 13 { |
14 let result1 = triggeredListeners = []; | 14 let result1 = triggeredListeners = []; |
15 FilterNotifier.triggerListeners("foo", {bar: true}); | 15 FilterNotifier.triggerListeners("foo", {bar: true}); |
16 | 16 |
17 let result2 = triggeredListeners = []; | 17 let result2 = triggeredListeners = []; |
18 for each (let observer in list) | 18 for (let observer of list) |
19 observer("foo", {bar: true}); | 19 observer("foo", {bar: true}); |
20 | 20 |
21 deepEqual(result1, result2, test); | 21 deepEqual(result1, result2, test); |
22 } | 22 } |
23 | 23 |
24 test("Adding/removing listeners", function() | 24 test("Adding/removing listeners", function() |
25 { | 25 { |
26 let [listener1, listener2, listener3] = listeners; | 26 let [listener1, listener2, listener3] = listeners; |
27 | 27 |
28 compareListeners("No listeners", []); | 28 compareListeners("No listeners", []); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 FilterNotifier.removeListener(listener1); | 66 FilterNotifier.removeListener(listener1); |
67 }; | 67 }; |
68 let listener2 = listeners[1]; | 68 let listener2 = listeners[1]; |
69 FilterNotifier.addListener(listener1); | 69 FilterNotifier.addListener(listener1); |
70 FilterNotifier.addListener(listener2); | 70 FilterNotifier.addListener(listener2); |
71 | 71 |
72 compareListeners("Initial call", [listener1, listener2]); | 72 compareListeners("Initial call", [listener1, listener2]); |
73 compareListeners("Subsequent calls", [listener2]); | 73 compareListeners("Subsequent calls", [listener2]); |
74 }); | 74 }); |
75 })(); | 75 })(); |
OLD | NEW |