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

Unified Diff: test/filterStorage.js

Issue 29886685: Issue 6856 - Remove FilterStorage.moveSubscription (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Address PS4 Comment Created Oct. 1, 2018, 2:31 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/filterStorage.js
===================================================================
--- a/test/filterStorage.js
+++ b/test/filterStorage.js
@@ -41,43 +41,42 @@
function addListener(listener)
{
let makeWrapper = name => (...args) => listener(name, ...args);
filterNotifier.on("subscription.added", makeWrapper("subscription.added"));
filterNotifier.on("subscription.removed",
makeWrapper("subscription.removed"));
- filterNotifier.on("subscription.moved", makeWrapper("subscription.moved"));
filterNotifier.on("filter.added", makeWrapper("filter.added"));
filterNotifier.on("filter.removed", makeWrapper("filter.removed"));
filterNotifier.on("filter.moved", makeWrapper("filter.moved"));
filterNotifier.on("filter.hitCount", makeWrapper("filter.hitCount"));
filterNotifier.on("filter.lastHit", makeWrapper("filter.lastHit"));
}
function compareSubscriptionList(test, testMessage, list,
knownSubscriptions = null)
{
- let result = FilterStorage.subscriptions.map(subscription => subscription.url);
+ let result = [...FilterStorage.knownSubscriptions.keys()];
let expected = list.map(subscription => subscription.url);
test.deepEqual(result, expected, testMessage);
if (knownSubscriptions)
{
test.deepEqual([...Subscription.knownSubscriptions.values()],
knownSubscriptions, testMessage);
}
}
function compareFiltersList(test, testMessage, list)
{
- let result = FilterStorage.subscriptions.map(
+ let result = [...FilterStorage.subscriptions()].map(
subscription => subscription.filters.map(
filter => filter.text));
test.deepEqual(result, list, testMessage);
}
function compareFilterSubscriptions(test, testMessage, filter, list)
{
let result = [...filter.subscriptions()].map(subscription => subscription.url);
@@ -203,48 +202,18 @@
if (action.indexOf("subscription.") == 0)
changes.push(action + " " + subscription.url);
}
addListener(listener);
compareSubscriptionList(test, "Initial state", [subscription1, subscription2, subscription3]);
test.deepEqual(changes, [], "Received changes");
- changes = [];
- FilterStorage.moveSubscription(subscription1);
- compareSubscriptionList(test, "Move without explicit position", [subscription2, subscription3, subscription1]);
- test.deepEqual(changes, ["subscription.moved http://test1/"], "Received changes");
-
- changes = [];
- FilterStorage.moveSubscription(subscription1);
- compareSubscriptionList(test, "Move without explicit position (subscription already last)", [subscription2, subscription3, subscription1]);
- test.deepEqual(changes, [], "Received changes");
-
- changes = [];
- FilterStorage.moveSubscription(subscription2, subscription1);
- compareSubscriptionList(test, "Move with explicit position", [subscription3, subscription2, subscription1]);
- test.deepEqual(changes, ["subscription.moved http://test2/"], "Received changes");
-
- changes = [];
- FilterStorage.moveSubscription(subscription3, subscription2);
- compareSubscriptionList(test, "Move without explicit position (subscription already at position)", [subscription3, subscription2, subscription1]);
- test.deepEqual(changes, [], "Received changes");
-
FilterStorage.removeSubscription(subscription2);
- compareSubscriptionList(test, "Remove", [subscription3, subscription1]);
-
- changes = [];
- FilterStorage.moveSubscription(subscription3, subscription2);
- compareSubscriptionList(test, "Move before removed subscription", [subscription1, subscription3]);
- test.deepEqual(changes, ["subscription.moved http://test3/"], "Received changes");
-
- changes = [];
- FilterStorage.moveSubscription(subscription2);
- compareSubscriptionList(test, "Move of removed subscription", [subscription1, subscription3]);
- test.deepEqual(changes, [], "Received changes");
+ compareSubscriptionList(test, "Remove", [subscription1, subscription3]);
test.done();
};
exports.testAddingFilters = function(test)
{
let subscription1 = Subscription.fromURL("~blocking");
subscription1.defaults = ["blocking"];
« lib/filterStorage.js ('K') | « lib/synchronizer.js ('k') | test/filterStorage_readwrite.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld