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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 let { | 20 let {createSandbox} = require("./common"); |
21 Subscription, SpecialSubscription, DownloadableSubscription, | 21 |
22 RegularSubscription, ExternalSubscription | 22 let Subscription = null; |
23 } = require("../lib/subscriptionClasses"); | 23 let SpecialSubscription = null; |
| 24 let DownloadableSubscription = null; |
| 25 let RegularSubscription = null; |
| 26 let ExternalSubscription = null; |
| 27 |
| 28 exports.setUp = function(callback) |
| 29 { |
| 30 let sandboxedRequire = createSandbox(); |
| 31 ( |
| 32 {Subscription, SpecialSubscription, |
| 33 DownloadableSubscription, RegularSubscription, |
| 34 ExternalSubscription} = sandboxedRequire("subscriptionClasses") |
| 35 ); |
| 36 |
| 37 callback(); |
| 38 }; |
24 | 39 |
25 function compareSubscription(test, url, expected, postInit) | 40 function compareSubscription(test, url, expected, postInit) |
26 { | 41 { |
27 expected.push("[Subscription]") | 42 expected.push("[Subscription]"); |
28 let subscription = Subscription.fromURL(url); | 43 let subscription = Subscription.fromURL(url); |
29 if (postInit) | 44 if (postInit) |
30 postInit(subscription) | 45 postInit(subscription); |
31 let result = []; | 46 let result = []; |
32 subscription.serialize(result); | 47 subscription.serialize(result); |
33 test.equal(result.sort().join("\n"), expected.sort().join("\n"), url); | 48 test.equal(result.sort().join("\n"), expected.sort().join("\n"), url); |
34 | 49 |
35 let map = Object.create(null); | 50 let map = Object.create(null); |
36 for (let line of result.slice(1)) | 51 for (let line of result.slice(1)) |
37 { | 52 { |
38 if (/(.*?)=(.*)/.test(line)) | 53 if (/(.*?)=(.*)/.test(line)) |
39 map[RegExp.$1] = RegExp.$2; | 54 map[RegExp.$1] = RegExp.$2; |
40 } | 55 } |
(...skipping 26 matching lines...) Expand all Loading... |
67 { | 82 { |
68 subscription.title = "test"; | 83 subscription.title = "test"; |
69 subscription.disabled = true; | 84 subscription.disabled = true; |
70 subscription.lastSuccess = 8; | 85 subscription.lastSuccess = 8; |
71 subscription.lastDownload = 12; | 86 subscription.lastDownload = 12; |
72 subscription.lastCheck = 16; | 87 subscription.lastCheck = 16; |
73 subscription.softExpiration = 18; | 88 subscription.softExpiration = 18; |
74 subscription.expires = 20; | 89 subscription.expires = 20; |
75 subscription.downloadStatus = "foo"; | 90 subscription.downloadStatus = "foo"; |
76 subscription.errors = 3; | 91 subscription.errors = 3; |
77 subscription.version = 24 | 92 subscription.version = 24; |
78 subscription.requiredVersion = "0.6"; | 93 subscription.requiredVersion = "0.6"; |
79 }); | 94 }); |
80 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
oup"], function(subscription) | 95 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
oup"], function(subscription) |
81 { | 96 { |
82 subscription.title = "Test group"; | 97 subscription.title = "Test group"; |
83 subscription.disabled = true; | 98 subscription.disabled = true; |
84 }); | 99 }); |
85 | 100 |
86 test.done(); | 101 test.done(); |
87 }; | 102 }; |
OLD | NEW |