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

Side by Side Diff: test/filterStorage_readwrite.js

Issue 29886685: Issue 6856 - Remove FilterStorage.moveSubscription (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Address PS5 Comments Created Oct. 1, 2018, 3:40 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/filterStorage.js ('k') | test/synchronizer.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
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version"); 104 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version");
105 105
106 if (withExternal) 106 if (withExternal)
107 { 107 {
108 { 108 {
109 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription"); 109 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription");
110 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")]; 110 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")];
111 FilterStorage.addSubscription(subscription); 111 FilterStorage.addSubscription(subscription);
112 } 112 }
113 113
114 let externalSubscriptions = FilterStorage.subscriptions.filter(subscriptio n => subscription instanceof ExternalSubscription); 114 let externalSubscriptions = [...FilterStorage.subscriptions()].filter(subs cription => subscription instanceof ExternalSubscription);
115 test.equal(externalSubscriptions.length, 1, "Number of external subscripti ons after updateExternalSubscription"); 115 test.equal(externalSubscriptions.length, 1, "Number of external subscripti ons after updateExternalSubscription");
116 116
117 test.equal(externalSubscriptions[0].url, "~external~external subscription ID", "ID of external subscription"); 117 test.equal(externalSubscriptions[0].url, "~external~external subscription ID", "ID of external subscription");
118 test.equal(externalSubscriptions[0].filters.length, 2, "Number of filters in external subscription"); 118 test.equal(externalSubscriptions[0].filters.length, 2, "Number of filters in external subscription");
119 } 119 }
120 120
121 return FilterStorage.saveToDisk(); 121 return FilterStorage.saveToDisk();
122 }).then(() => testData).then(expected => 122 }).then(() => testData).then(expected =>
123 { 123 {
124 test.deepEqual(canonize(IO._getFileContents(FilterStorage.sourceFile)), 124 test.deepEqual(canonize(IO._getFileContents(FilterStorage.sourceFile)),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 }).catch(unexpectedError.bind(test)).then(() => test.done()); 223 }).catch(unexpectedError.bind(test)).then(() => test.done());
224 }; 224 };
225 225
226 exports.testRestoringBackup = function(test) 226 exports.testRestoringBackup = function(test)
227 { 227 {
228 Prefs.patternsbackups = 2; 228 Prefs.patternsbackups = 2;
229 Prefs.patternsbackupinterval = 24; 229 Prefs.patternsbackupinterval = 24;
230 230
231 FilterStorage.saveToDisk().then(() => 231 FilterStorage.saveToDisk().then(() =>
232 { 232 {
233 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Initial filter count"); 233 test.equal([...FilterStorage.subscriptions()][0].filters.length, 1, "Initial filter count");
234 FilterStorage.addFilter(Filter.fromText("barfoo")); 234 FilterStorage.addFilter(Filter.fromText("barfoo"));
235 test.equal(FilterStorage.subscriptions[0].filters.length, 2, "Filter count a fter adding a filter"); 235 test.equal([...FilterStorage.subscriptions()][0].filters.length, 2, "Filter count after adding a filter");
236 return FilterStorage.saveToDisk(); 236 return FilterStorage.saveToDisk();
237 }).then(() => 237 }).then(() =>
238 { 238 {
239 return FilterStorage.loadFromDisk(); 239 return FilterStorage.loadFromDisk();
240 }).then(() => 240 }).then(() =>
241 { 241 {
242 test.equal(FilterStorage.subscriptions[0].filters.length, 2, "Filter count a fter adding filter and reloading"); 242 test.equal([...FilterStorage.subscriptions()][0].filters.length, 2, "Filter count after adding filter and reloading");
243 return FilterStorage.restoreBackup(1); 243 return FilterStorage.restoreBackup(1);
244 }).then(() => 244 }).then(() =>
245 { 245 {
246 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter restoring backup"); 246 test.equal([...FilterStorage.subscriptions()][0].filters.length, 1, "Filter count after restoring backup");
247 return FilterStorage.loadFromDisk(); 247 return FilterStorage.loadFromDisk();
248 }).then(() => 248 }).then(() =>
249 { 249 {
250 test.equal(FilterStorage.subscriptions[0].filters.length, 1, "Filter count a fter reloading"); 250 test.equal([...FilterStorage.subscriptions()][0].filters.length, 1, "Filter count after reloading");
251 }).catch(unexpectedError.bind(test)).then(() => test.done()); 251 }).catch(unexpectedError.bind(test)).then(() => test.done());
252 }; 252 };
OLDNEW
« no previous file with comments | « test/filterStorage.js ('k') | test/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld