| OLD | NEW |
| (Empty) |
| 1 (function() | |
| 2 { | |
| 3 module("Subscription classes", {setup: prepareFilterComponents, teardown: rest
oreFilterComponents}); | |
| 4 | |
| 5 function compareSubscription(url, expected, postInit) | |
| 6 { | |
| 7 expected.push("[Subscription]") | |
| 8 let subscription = Subscription.fromURL(url); | |
| 9 if (postInit) | |
| 10 postInit(subscription) | |
| 11 let result = []; | |
| 12 subscription.serialize(result); | |
| 13 equal(result.sort().join("\n"), expected.sort().join("\n"), url); | |
| 14 | |
| 15 let map = Object.create(null); | |
| 16 for (let line of result.slice(1)) | |
| 17 { | |
| 18 if (/(.*?)=(.*)/.test(line)) | |
| 19 map[RegExp.$1] = RegExp.$2; | |
| 20 } | |
| 21 let subscription2 = Subscription.fromObject(map); | |
| 22 equal(subscription.toString(), subscription2.toString(), url + " deserializa
tion"); | |
| 23 } | |
| 24 | |
| 25 test("Subscription class definitions", function() | |
| 26 { | |
| 27 equal(typeof Subscription, "function", "typeof Subscription"); | |
| 28 equal(typeof SpecialSubscription, "function", "typeof SpecialSubscription"); | |
| 29 equal(typeof RegularSubscription, "function", "typeof RegularSubscription"); | |
| 30 equal(typeof ExternalSubscription, "function", "typeof ExternalSubscription"
); | |
| 31 equal(typeof DownloadableSubscription, "function", "typeof DownloadableSubsc
ription"); | |
| 32 }); | |
| 33 | |
| 34 test("Subscriptions with state", function() | |
| 35 { | |
| 36 compareSubscription("~fl~", ["url=~fl~"]); | |
| 37 compareSubscription("http://test/default", ["url=http://test/default", "titl
e=http://test/default"]); | |
| 38 compareSubscription("http://test/default_titled", ["url=http://test/default_
titled", "title=test"], function(subscription) | |
| 39 { | |
| 40 subscription.title = "test"; | |
| 41 }); | |
| 42 compareSubscription("http://test/non_default", ["url=http://test/non_default
", "title=test", | |
| 43 "disabled=true", "lastSucces
s=8", "lastDownload=12", "lastCheck=16", "softExpiration=18", "expires=20", "dow
nloadStatus=foo", | |
| 44 "errors=3", "version=24", "r
equiredVersion=0.6"], function(subscription) | |
| 45 { | |
| 46 subscription.title = "test"; | |
| 47 subscription.disabled = true; | |
| 48 subscription.lastSuccess = 8; | |
| 49 subscription.lastDownload = 12; | |
| 50 subscription.lastCheck = 16; | |
| 51 subscription.softExpiration = 18; | |
| 52 subscription.expires = 20; | |
| 53 subscription.downloadStatus = "foo"; | |
| 54 subscription.errors = 3; | |
| 55 subscription.version = 24 | |
| 56 subscription.requiredVersion = "0.6"; | |
| 57 }); | |
| 58 compareSubscription("~wl~", ["url=~wl~", "disabled=true", "title=Test group"
], function(subscription) | |
| 59 { | |
| 60 subscription.title = "Test group"; | |
| 61 subscription.disabled = true; | |
| 62 }); | |
| 63 }); | |
| 64 })(); | |
| OLD | NEW |