Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/filterNotifier.js

Issue 29868577: Issue 6891 - Rename FilterNotifier to filterNotifier (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 29, 2018, 2 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/synchronizer.js ('k') | test/filterStorage.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 const {createSandbox} = require("./_common"); 20 const {createSandbox} = require("./_common");
21 21
22 let FilterNotifier = null; 22 let filterNotifier = null;
23 23
24 exports.setUp = function(callback) 24 exports.setUp = function(callback)
25 { 25 {
26 let sandboxedRequire = createSandbox(); 26 let sandboxedRequire = createSandbox();
27 ( 27 (
28 {FilterNotifier} = sandboxedRequire("../lib/filterNotifier") 28 {filterNotifier} = sandboxedRequire("../lib/filterNotifier")
29 ); 29 );
30 30
31 callback(); 31 callback();
32 }; 32 };
33 33
34 let triggeredListeners = []; 34 let triggeredListeners = [];
35 let listeners = [ 35 let listeners = [
36 (...args) => triggeredListeners.push(["listener1", ...args]), 36 (...args) => triggeredListeners.push(["listener1", ...args]),
37 (...args) => triggeredListeners.push(["listener2", ...args]), 37 (...args) => triggeredListeners.push(["listener2", ...args]),
38 (...args) => triggeredListeners.push(["listener3", ...args]) 38 (...args) => triggeredListeners.push(["listener3", ...args])
39 ]; 39 ];
40 40
41 function addListener(listener) 41 function addListener(listener)
42 { 42 {
43 FilterNotifier.on("foo", listener); 43 filterNotifier.on("foo", listener);
44 } 44 }
45 45
46 function removeListener(listener) 46 function removeListener(listener)
47 { 47 {
48 FilterNotifier.off("foo", listener); 48 filterNotifier.off("foo", listener);
49 } 49 }
50 50
51 function compareListeners(test, testDescription, list) 51 function compareListeners(test, testDescription, list)
52 { 52 {
53 let result1 = triggeredListeners = []; 53 let result1 = triggeredListeners = [];
54 FilterNotifier.emit("foo", {bar: true}); 54 filterNotifier.emit("foo", {bar: true});
55 55
56 let result2 = triggeredListeners = []; 56 let result2 = triggeredListeners = [];
57 for (let observer of list) 57 for (let observer of list)
58 observer({bar: true}); 58 observer({bar: true});
59 59
60 test.deepEqual(result1, result2, testDescription); 60 test.deepEqual(result1, result2, testDescription);
61 } 61 }
62 62
63 exports.testAddingRemovingListeners = function(test) 63 exports.testAddingRemovingListeners = function(test)
64 { 64 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }; 108 };
109 let listener2 = listeners[1]; 109 let listener2 = listeners[1];
110 addListener(listener1); 110 addListener(listener1);
111 addListener(listener2); 111 addListener(listener2);
112 112
113 compareListeners(test, "Initial call", [listener1, listener2]); 113 compareListeners(test, "Initial call", [listener1, listener2]);
114 compareListeners(test, "Subsequent calls", [listener2]); 114 compareListeners(test, "Subsequent calls", [listener2]);
115 115
116 test.done(); 116 test.done();
117 }; 117 };
OLDNEW
« no previous file with comments | « lib/synchronizer.js ('k') | test/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld