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

Side by Side Diff: chrome/content/tests/notification.js

Issue 11127037: Notifications: implemented better target checks - unit tests (Closed)
Patch Set: Better pair generation Created July 25, 2013, 11:11 a.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 | « no previous file | 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 (function() 1 (function()
2 { 2 {
3 let testRunner = null; 3 let testRunner = null;
4 let server = null; 4 let server = null;
5 let randomResult = 0.5; 5 let randomResult = 0.5;
6 6
7 let originalInfo; 7 let originalInfo;
8 let info = require("info"); 8 let info = require("info");
9 9
10 module("Notification handling", 10 module("Notification handling",
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 Prefs.notificationdata = {}; 202 Prefs.notificationdata = {};
203 registerHandler([information]); 203 registerHandler([information]);
204 testRunner.runScheduledTasks(1); 204 testRunner.runScheduledTasks(1);
205 205
206 let expected = (result ? information : null); 206 let expected = (result ? information : null);
207 deepEqual(Notification.getNextToShow(), expected, "Selected notification f or " + JSON.stringify(information.targets)); 207 deepEqual(Notification.getNextToShow(), expected, "Selected notification f or " + JSON.stringify(information.targets));
208 deepEqual(Notification.getNextToShow(), null, "No notification on second c all"); 208 deepEqual(Notification.getNextToShow(), null, "No notification on second c all");
209 } 209 }
210 210
211 function allPairs(array) 211 function pairs(array)
212 { 212 {
213 var pairs = []; 213 for each (let element1 in array)
214 for (var i = 0; i < array.length - 1; i++) 214 for each (let element2 in array)
215 for (var j = i + 1; j < array.length; j++) 215 yield [element1, element2];
216 pairs.push([array[i], array[j]]);
217 return pairs;
218 } 216 }
219 for each (let [[propName1, value1, result1], [propName2, value2, result2]] i n allPairs(targets)) 217 for (let [[propName1, value1, result1], [propName2, value2, result2]] in pai rs(targets))
220 { 218 {
221 let targetInfo1 = {}; 219 let targetInfo1 = {};
222 targetInfo1[propName1] = value1; 220 targetInfo1[propName1] = value1;
223 let targetInfo2 = {}; 221 let targetInfo2 = {};
224 targetInfo2[propName2] = value2; 222 targetInfo2[propName2] = value2;
225 223
226 let information = fixConstructors({ 224 let information = fixConstructors({
227 id: 1, 225 id: 1,
228 severity: "information", 226 severity: "information",
229 message: {"en-US": "Information"}, 227 message: {"en-US": "Information"},
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 equal(texts.message, "fr"); 278 equal(texts.message, "fr");
281 }); 279 });
282 280
283 test("Missing translation", function() 281 test("Missing translation", function()
284 { 282 {
285 let notification = {message: {"en-US": "en-US"}}; 283 let notification = {message: {"en-US": "en-US"}};
286 let texts = Notification.getLocalizedTexts(notification, "fr"); 284 let texts = Notification.getLocalizedTexts(notification, "fr");
287 equal(texts.message, "en-US"); 285 equal(texts.message, "en-US");
288 }); 286 });
289 })(); 287 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld