OLD | NEW |
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 Loading... |
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 Loading... |
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 }; |
OLD | NEW |