| Left: | ||
| Right: |
| 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", | 27 Object.defineProperty(Utils, "appLocale", |
| 28 {value: "en", enumerable: true}); | 28 {value: "en", enumerable: true}); |
| 29 }, | |
| 30 | |
| 31 teardown() | |
| 32 { | |
| 33 // TODO restore appLocale | |
|
Manish Jethani
2018/06/14 05:07:34
We don't normally leave "todo" comments in the cod
hub
2018/06/14 19:59:57
I had forgotten to remove it, done.
| |
| 34 } | 29 } |
| 35 }); | 30 }); |
| 36 | 31 |
| 37 | 32 |
| 38 test("Choosing filter subscriptions", assert => | 33 test("Choosing filter subscriptions", assert => |
| 39 { | 34 { |
| 40 let done = assert.async(); | 35 let done = assert.async(); |
| 41 fetch("subscriptions.xml") | 36 fetch("subscriptions.xml") |
| 42 .then(response => response.text()) | 37 .then(response => response.text()) |
| 43 .then(text => | 38 .then(text => |
| 44 { | 39 { |
| 45 let doc = new DOMParser().parseFromString(text, "application/xml"); | 40 let doc = new DOMParser().parseFromString(text, "application/xml"); |
| 46 let nodes = doc.getElementsByTagName("subscription"); | 41 let nodes = doc.getElementsByTagName("subscription"); |
| 47 | 42 |
| 48 let subs = chooseFilterSubscriptions(nodes); | 43 let subs = chooseFilterSubscriptions(nodes); |
| 49 assert.ok(subs); | 44 assert.ok(subs); |
| 50 assert.ok(subs.circumvention); | 45 assert.ok(subs.circumvention); |
| 51 assert.ok(subs.ads); | 46 assert.ok(subs.ads); |
| 52 | 47 |
| 53 assert.equal(subs.circumvention.getAttribute("prefixes"), "en"); | 48 assert.equal(subs.circumvention.getAttribute("prefixes"), |
| 49 "de,en,en-US"); | |
| 54 assert.equal(subs.circumvention.getAttribute("type"), "circumvention"); | 50 assert.equal(subs.circumvention.getAttribute("type"), "circumvention"); |
| 55 assert.equal(subs.ads.getAttribute("prefixes"), "en"); | 51 assert.equal(subs.ads.getAttribute("prefixes"), "en"); |
| 56 assert.equal(subs.ads.getAttribute("type"), "ads"); | 52 assert.equal(subs.ads.getAttribute("type"), "ads"); |
| 57 | 53 |
| 58 done(); | 54 done(); |
| 59 }) | 55 }) |
| 60 .catch(() => | 56 .catch(() => |
| 61 { | 57 { |
| 62 assert.ok(false); | 58 assert.ok(false); |
| 63 | 59 |
| 64 done(); | 60 done(); |
| 65 }); | 61 }); |
| 66 }); | 62 }); |
| 67 } | 63 } |
| LEFT | RIGHT |