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

Side by Side Diff: test/subscriptionClasses.js

Issue 29336491: Issue 3660 - Remove locale dependency from subscription classes (Closed)
Patch Set: Created Feb. 16, 2016, 12:23 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 | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 "use strict";
19
20 let {
21 Subscription, SpecialSubscription, DownloadableSubscription,
22 RegularSubscription, ExternalSubscription
23 } = require("../lib/subscriptionClasses");
24
25 function compareSubscription(test, url, expected, postInit)
26 {
27 expected.push("[Subscription]")
28 let subscription = Subscription.fromURL(url);
29 if (postInit)
30 postInit(subscription)
31 let result = [];
32 subscription.serialize(result);
33 test.equal(result.sort().join("\n"), expected.sort().join("\n"), url);
34
35 let map = {__proto__: null};
36 for (let line of result.slice(1))
37 {
38 if (/(.*?)=(.*)/.test(line))
39 map[RegExp.$1] = RegExp.$2;
40 }
41 let subscription2 = Subscription.fromObject(map);
42 test.equal(subscription.toString(), subscription2.toString(), url + " deserial ization");
43 }
44
45 exports.testSubscriptionClassDefinitions = function(test)
46 {
47 test.equal(typeof Subscription, "function", "typeof Subscription");
48 test.equal(typeof SpecialSubscription, "function", "typeof SpecialSubscription ");
49 test.equal(typeof RegularSubscription, "function", "typeof RegularSubscription ");
50 test.equal(typeof ExternalSubscription, "function", "typeof ExternalSubscripti on");
51 test.equal(typeof DownloadableSubscription, "function", "typeof DownloadableSu bscription");
52
53 test.done();
54 };
55
56 exports.testSubscriptionsWithState = function(test)
57 {
58 compareSubscription(test, "~fl~", ["url=~fl~"]);
59 compareSubscription(test, "http://test/default", ["url=http://test/default", " title=http://test/default"]);
60 compareSubscription(test, "http://test/default_titled", ["url=http://test/defa ult_titled", "title=test"], function(subscription)
61 {
62 subscription.title = "test";
63 });
64 compareSubscription(test, "http://test/non_default", ["url=http://test/non_def ault", "title=test",
65 "disabled=true", "lastSuccess= 8", "lastDownload=12", "lastCheck=16", "softExpiration=18", "expires=20", "downl oadStatus=foo",
66 "errors=3", "version=24", "req uiredVersion=0.6"], function(subscription)
67 {
68 subscription.title = "test";
69 subscription.disabled = true;
70 subscription.lastSuccess = 8;
71 subscription.lastDownload = 12;
72 subscription.lastCheck = 16;
73 subscription.softExpiration = 18;
74 subscription.expires = 20;
75 subscription.downloadStatus = "foo";
76 subscription.errors = 3;
77 subscription.version = 24
78 subscription.requiredVersion = "0.6";
79 });
80 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr oup"], function(subscription)
81 {
82 subscription.title = "Test group";
83 subscription.disabled = true;
84 });
85
86 test.done();
87 };
OLDNEW
« no previous file with comments | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld