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

Unified Diff: test/filterStorage.js

Issue 29934588: Issue 7094 - Encapsulate management of subscription filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Simplify patch Created Nov. 17, 2018, 9:25 p.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
@@ -67,18 +67,17 @@
test.deepEqual([...Subscription.knownSubscriptions.values()],
knownSubscriptions, testMessage);
}
}
function compareFiltersList(test, testMessage, list)
{
let result = [...filterStorage.subscriptions()].map(
- subscription => subscription.filters.map(
- filter => filter.text));
+ subscription => [...subscription.filterText()]);
test.deepEqual(result, list, testMessage);
}
function compareFilterSubscriptions(test, testMessage, filter, list)
{
let result = [...filter.subscriptions()].map(subscription => subscription.url);
let expected = list.map(subscription => subscription.url);
test.deepEqual(result, expected, testMessage);
@@ -286,23 +285,28 @@
test.deepEqual(changes, ["filter.added !foobar"], "Received changes");
test.done();
};
exports.testRemovingFilters = function(test)
{
let subscription1 = Subscription.fromURL("~foo");
- subscription1.filters = [Filter.fromText("foo"), Filter.fromText("foo"), Filter.fromText("bar")];
+ subscription1.addFilter(Filter.fromText("foo"));
+ subscription1.addFilter(Filter.fromText("foo"));
+ subscription1.addFilter(Filter.fromText("bar"));
let subscription2 = Subscription.fromURL("~bar");
- subscription2.filters = [Filter.fromText("foo"), Filter.fromText("bar"), Filter.fromText("foo")];
+ subscription2.addFilter(Filter.fromText("foo"));
+ subscription2.addFilter(Filter.fromText("bar"));
+ subscription2.addFilter(Filter.fromText("foo"));
let subscription3 = Subscription.fromURL("http://test/");
- subscription3.filters = [Filter.fromText("foo"), Filter.fromText("bar")];
+ subscription3.addFilter(Filter.fromText("foo"));
+ subscription3.addFilter(Filter.fromText("bar"));
filterStorage.addSubscription(subscription1);
filterStorage.addSubscription(subscription2);
filterStorage.addSubscription(subscription3);
let changes = [];
function listener(action, filter)
{
@@ -345,20 +349,24 @@
test.deepEqual(changes, [], "Received changes");
test.done();
};
exports.testMovingFilters = function(test)
{
let subscription1 = Subscription.fromURL("~foo");
- subscription1.filters = [Filter.fromText("foo"), Filter.fromText("bar"), Filter.fromText("bas"), Filter.fromText("foo")];
+ subscription1.addFilter(Filter.fromText("foo"));
+ subscription1.addFilter(Filter.fromText("bar"));
+ subscription1.addFilter(Filter.fromText("bas"));
+ subscription1.addFilter(Filter.fromText("foo"));
let subscription2 = Subscription.fromURL("http://test/");
- subscription2.filters = [Filter.fromText("foo"), Filter.fromText("bar")];
+ subscription2.addFilter(Filter.fromText("foo"));
+ subscription2.addFilter(Filter.fromText("bar"));
filterStorage.addSubscription(subscription1);
filterStorage.addSubscription(subscription2);
let changes = [];
function listener(action, filter)
{
if (action.indexOf("filter.") == 0)
@@ -446,23 +454,27 @@
exports.testFilterSubscriptionRelationship = function(test)
{
let filter1 = Filter.fromText("filter1");
let filter2 = Filter.fromText("filter2");
let filter3 = Filter.fromText("filter3");
let subscription1 = Subscription.fromURL("http://test1/");
- subscription1.filters = [filter1, filter2];
+ subscription1.addFilter(filter1);
+ subscription1.addFilter(filter2);
let subscription2 = Subscription.fromURL("http://test2/");
- subscription2.filters = [filter2, filter3];
+ subscription2.addFilter(filter2);
+ subscription2.addFilter(filter3);
let subscription3 = Subscription.fromURL("http://test3/");
- subscription3.filters = [filter1, filter2, filter3];
+ subscription3.addFilter(filter1);
+ subscription3.addFilter(filter2);
+ subscription3.addFilter(filter3);
compareFilterSubscriptions(test, "Initial filter1 subscriptions", filter1, []);
compareFilterSubscriptions(test, "Initial filter2 subscriptions", filter2, []);
compareFilterSubscriptions(test, "Initial filter3 subscriptions", filter3, []);
filterStorage.addSubscription(subscription1);
compareFilterSubscriptions(test, "filter1 subscriptions after adding http://test1/", filter1, [subscription1]);

Powered by Google App Engine
This is Rietveld