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

Side by Side Diff: test/filterStorage.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 | « test/filterNotifier.js ('k') | no next file » | 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 Filter = null; 22 let Filter = null;
23 let FilterNotifier = null; 23 let filterNotifier = null;
24 let FilterStorage = null; 24 let FilterStorage = null;
25 let Subscription = null; 25 let Subscription = null;
26 26
27 exports.setUp = function(callback) 27 exports.setUp = function(callback)
28 { 28 {
29 let sandboxedRequire = createSandbox(); 29 let sandboxedRequire = createSandbox();
30 30
31 sandboxedRequire("../lib/filterListener"); 31 sandboxedRequire("../lib/filterListener");
32 ( 32 (
33 {Filter} = sandboxedRequire("../lib/filterClasses"), 33 {Filter} = sandboxedRequire("../lib/filterClasses"),
34 {FilterNotifier} = sandboxedRequire("../lib/filterNotifier"), 34 {filterNotifier} = sandboxedRequire("../lib/filterNotifier"),
35 {FilterStorage} = sandboxedRequire("../lib/filterStorage"), 35 {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
36 {Subscription} = sandboxedRequire("../lib/subscriptionClasses") 36 {Subscription} = sandboxedRequire("../lib/subscriptionClasses")
37 ); 37 );
38 38
39 callback(); 39 callback();
40 }; 40 };
41 41
42 function addListener(listener) 42 function addListener(listener)
43 { 43 {
44 let makeWrapper = name => (...args) => listener(name, ...args); 44 let makeWrapper = name => (...args) => listener(name, ...args);
45 45
46 FilterNotifier.on("subscription.added", makeWrapper("subscription.added")); 46 filterNotifier.on("subscription.added", makeWrapper("subscription.added"));
47 FilterNotifier.on("subscription.removed", 47 filterNotifier.on("subscription.removed",
48 makeWrapper("subscription.removed")); 48 makeWrapper("subscription.removed"));
49 FilterNotifier.on("subscription.moved", makeWrapper("subscription.moved")); 49 filterNotifier.on("subscription.moved", makeWrapper("subscription.moved"));
50 50
51 FilterNotifier.on("filter.added", makeWrapper("filter.added")); 51 filterNotifier.on("filter.added", makeWrapper("filter.added"));
52 FilterNotifier.on("filter.removed", makeWrapper("filter.removed")); 52 filterNotifier.on("filter.removed", makeWrapper("filter.removed"));
53 FilterNotifier.on("filter.moved", makeWrapper("filter.moved")); 53 filterNotifier.on("filter.moved", makeWrapper("filter.moved"));
54 54
55 FilterNotifier.on("filter.hitCount", makeWrapper("filter.hitCount")); 55 filterNotifier.on("filter.hitCount", makeWrapper("filter.hitCount"));
56 FilterNotifier.on("filter.lastHit", makeWrapper("filter.lastHit")); 56 filterNotifier.on("filter.lastHit", makeWrapper("filter.lastHit"));
57 } 57 }
58 58
59 function compareSubscriptionList(test, testMessage, list, 59 function compareSubscriptionList(test, testMessage, list,
60 knownSubscriptions = null) 60 knownSubscriptions = null)
61 { 61 {
62 let result = FilterStorage.subscriptions.map(subscription => subscription.url) ; 62 let result = FilterStorage.subscriptions.map(subscription => subscription.url) ;
63 let expected = list.map(subscription => subscription.url); 63 let expected = list.map(subscription => subscription.url);
64 test.deepEqual(result, expected, testMessage); 64 test.deepEqual(result, expected, testMessage);
65 65
66 if (knownSubscriptions) 66 if (knownSubscriptions)
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]); 531 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]);
532 532
533 FilterStorage.removeSubscription(subscription3); 533 FilterStorage.removeSubscription(subscription3);
534 534
535 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []); 535 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []);
536 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]); 536 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]);
537 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]); 537 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]);
538 538
539 test.done(); 539 test.done();
540 }; 540 };
OLDNEW
« no previous file with comments | « test/filterNotifier.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld