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

Side by Side Diff: test/filterStorage_readwrite.js

Issue 29402582: Issue 5098 - Expose FilterStorage initialization state (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created April 4, 2017, 12:51 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/filterStorage.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
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return 1; 103 return 1;
104 return 0; 104 return 0;
105 }); 105 });
106 return sections.map( 106 return sections.map(
107 section => [section.header].concat(section.data).join("\n") 107 section => [section.header].concat(section.data).join("\n")
108 ).join("\n"); 108 ).join("\n");
109 } 109 }
110 110
111 function testReadWrite(test, withExternal) 111 function testReadWrite(test, withExternal)
112 { 112 {
113 test.ok(!FilterStorage.initialized, "Not initialize before the first load");
kzar 2017/04/05 03:51:11 Nit: Should be "Uninitiated before...".
Wladimir Palant 2017/04/05 07:16:28 Done.
114
113 return testData.then(data => 115 return testData.then(data =>
114 { 116 {
115 dataFile.contents = data; 117 dataFile.contents = data;
116 return loadFilters(); 118 return loadFilters();
117 }).then(() => 119 }).then(() =>
118 { 120 {
121 test.ok(FilterStorage.initialized, "Initialize after the first load");
119 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version"); 122 test.equal(FilterStorage.fileProperties.version, FilterStorage.formatVersion , "File format version");
120 123
121 if (withExternal) 124 if (withExternal)
122 { 125 {
123 { 126 {
124 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription"); 127 let subscription = new ExternalSubscription("~external~external subscrip tion ID", "External subscription");
125 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")]; 128 subscription.filters = [Filter.fromText("foo"), Filter.fromText("bar")];
126 FilterStorage.addSubscription(subscription); 129 FilterStorage.addSubscription(subscription);
127 } 130 }
128 131
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return FilterStorage.restoreBackup(1); 324 return FilterStorage.restoreBackup(1);
322 }).then(() => 325 }).then(() =>
323 { 326 {
324 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after restoring backup"); 327 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after restoring backup");
325 return loadFilters(); 328 return loadFilters();
326 }).then(() => 329 }).then(() =>
327 { 330 {
328 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after reloading"); 331 test.equal(FilterStorage.subscriptions.length, 1, "Subscription count after reloading");
329 }).catch(unexpectedError.bind(test)).then(() => test.done()); 332 }).catch(unexpectedError.bind(test)).then(() => test.done());
330 }; 333 };
OLDNEW
« no previous file with comments | « lib/filterStorage.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld