LEFT | RIGHT |
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 |
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 { | 20 { |
21 let {chooseFilterSubscriptions} = require("../../lib/subscriptionInit"); | 21 let {chooseFilterSubscriptions} = require("../../lib/subscriptionInit"); |
22 | 22 |
23 QUnit.module("Subscription", { | 23 QUnit.module("Subscription", { |
24 setup() | 24 setup() |
25 { | 25 { |
26 let {Utils} = require("../../lib/utils"); | 26 let {Utils} = require("../../lib/utils"); |
27 Object.defineProperty(Utils, "appLocale", {value: "en", enumerable: true})
; | 27 Object.defineProperty(Utils, "appLocale", |
28 }, | 28 {value: "en", enumerable: true}); |
29 | |
30 teardown() | |
31 { | |
32 // TODO restore appLocale | |
33 } | 29 } |
34 }); | 30 }); |
35 | 31 |
36 | 32 |
37 test("Choosing filter subscriptions", assert => | 33 test("Choosing filter subscriptions", assert => |
38 { | 34 { |
39 let done = assert.async(); | 35 let done = assert.async(); |
40 fetch("subscriptions.xml") | 36 fetch("subscriptions.xml") |
41 .then(response => response.text()) | 37 .then(response => response.text()) |
42 .then(text => | 38 .then(text => |
43 { | 39 { |
44 let doc = new DOMParser().parseFromString(text, "application/xml"); | 40 let doc = new DOMParser().parseFromString(text, "application/xml"); |
45 let nodes = doc.getElementsByTagName("subscription"); | 41 let nodes = doc.getElementsByTagName("subscription"); |
46 | 42 |
47 let subs = chooseFilterSubscriptions(nodes); | 43 let subs = chooseFilterSubscriptions(nodes); |
48 assert.ok(subs); | 44 assert.ok(subs); |
49 assert.ok(subs.cv); | 45 assert.ok(subs.circumvention); |
50 assert.ok(subs.ads); | 46 assert.ok(subs.ads); |
51 | 47 |
52 assert.equal(subs.cv.getAttribute("prefixes"), "en"); | 48 assert.equal(subs.circumvention.getAttribute("prefixes"), |
53 assert.equal(subs.cv.getAttribute("type"), "cv"); | 49 "de,en,en-US"); |
| 50 assert.equal(subs.circumvention.getAttribute("type"), "circumvention"); |
54 assert.equal(subs.ads.getAttribute("prefixes"), "en"); | 51 assert.equal(subs.ads.getAttribute("prefixes"), "en"); |
55 assert.equal(subs.ads.getAttribute("type"), "ads"); | 52 assert.equal(subs.ads.getAttribute("type"), "ads"); |
56 | 53 |
57 done(); | 54 done(); |
58 }) | 55 }) |
59 .catch(() => | 56 .catch(() => |
60 { | 57 { |
61 assert.ok(false); | 58 assert.ok(false); |
62 | 59 |
63 done(); | 60 done(); |
64 }); | 61 }); |
65 }); | 62 }); |
66 } | 63 } |
LEFT | RIGHT |