OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 let testRunner = null; | 3 let testRunner = null; |
4 let randomResult = 0.5; | 4 let randomResult = 0.5; |
5 | 5 |
6 let originalInfo; | 6 let originalInfo; |
7 let info = require("info"); | 7 let info = require("info"); |
8 | 8 |
9 module("Notification handling", | 9 module("Notification handling", |
10 { | 10 { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ["platformMinVersion", "12", true], | 170 ["platformMinVersion", "12", true], |
171 ["platformMinVersion", "11", true], | 171 ["platformMinVersion", "11", true], |
172 ["platformMinVersion", "13", false], | 172 ["platformMinVersion", "13", false], |
173 ["platformMinVersion", "12.1", false], | 173 ["platformMinVersion", "12.1", false], |
174 ["platformMaxVersion", "12.0", true], | 174 ["platformMaxVersion", "12.0", true], |
175 ["platformMaxVersion", "12", true], | 175 ["platformMaxVersion", "12", true], |
176 ["platformMaxVersion", "13", true], | 176 ["platformMaxVersion", "13", true], |
177 ["platformMaxVersion", "11", false], | 177 ["platformMaxVersion", "11", false], |
178 ]; | 178 ]; |
179 | 179 |
180 for each (let [propName, value, result] in targets) | 180 for (let [propName, value, result] of targets) |
181 { | 181 { |
182 let targetInfo = {}; | 182 let targetInfo = {}; |
183 targetInfo[propName] = value; | 183 targetInfo[propName] = value; |
184 | 184 |
185 let information = fixConstructors({ | 185 let information = fixConstructors({ |
186 id: 1, | 186 id: 1, |
187 type: "information", | 187 type: "information", |
188 message: {"en-US": "Information"}, | 188 message: {"en-US": "Information"}, |
189 targets: [targetInfo] | 189 targets: [targetInfo] |
190 }); | 190 }); |
191 | 191 |
192 Prefs.notificationdata = {}; | 192 Prefs.notificationdata = {}; |
193 registerHandler([information]); | 193 registerHandler([information]); |
194 testRunner.runScheduledTasks(1); | 194 testRunner.runScheduledTasks(1); |
195 | 195 |
196 let expected = (result ? information : null); | 196 let expected = (result ? information : null); |
197 deepEqual(Notification.getNextToShow(), expected, "Selected notification f
or " + JSON.stringify(information.targets)); | 197 deepEqual(Notification.getNextToShow(), expected, "Selected notification f
or " + JSON.stringify(information.targets)); |
198 deepEqual(Notification.getNextToShow(), null, "No notification on second c
all"); | 198 deepEqual(Notification.getNextToShow(), null, "No notification on second c
all"); |
199 } | 199 } |
200 | 200 |
201 function pairs(array) | 201 function pairs(array) |
202 { | 202 { |
203 for each (let element1 in array) | 203 for (let element1 of array) |
204 for each (let element2 in array) | 204 for (let element2 of array) |
205 yield [element1, element2]; | 205 yield [element1, element2]; |
206 } | 206 } |
207 for (let [[propName1, value1, result1], [propName2, value2, result2]] in pai
rs(targets)) | 207 for (let [[propName1, value1, result1], [propName2, value2, result2]] in pai
rs(targets)) |
208 { | 208 { |
209 let targetInfo1 = {}; | 209 let targetInfo1 = {}; |
210 targetInfo1[propName1] = value1; | 210 targetInfo1[propName1] = value1; |
211 let targetInfo2 = {}; | 211 let targetInfo2 = {}; |
212 targetInfo2[propName2] = value2; | 212 targetInfo2[propName2] = value2; |
213 | 213 |
214 let information = fixConstructors({ | 214 let information = fixConstructors({ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 { | 296 { |
297 randomResult: 0.5, | 297 randomResult: 0.5, |
298 skipAfter: 5.2, | 298 skipAfter: 5.2, |
299 skip: 30, // Long break should increase soft expiration, h
itting hard expiration | 299 skip: 30, // Long break should increase soft expiration, h
itting hard expiration |
300 requests: [0.2, 48.2] | 300 requests: [0.2, 48.2] |
301 } | 301 } |
302 ]; | 302 ]; |
303 | 303 |
304 let requests = []; | 304 let requests = []; |
305 registerHandler([], function(metadata) requests.push(testRunner.getTimeOffse
t())); | 305 registerHandler([], function(metadata) requests.push(testRunner.getTimeOffse
t())); |
306 for each (let test in tests) | 306 for (let test of tests) |
307 { | 307 { |
308 Prefs.notificationdata = {}; | 308 Prefs.notificationdata = {}; |
309 requests = []; | 309 requests = []; |
310 randomResult = test.randomResult; | 310 randomResult = test.randomResult; |
311 | 311 |
312 let maxHours = Math.round(Math.max.apply(null, test.requests)) + 1; | 312 let maxHours = Math.round(Math.max.apply(null, test.requests)) + 1; |
313 testRunner.runScheduledTasks(maxHours, test.skipAfter, test.skip); | 313 testRunner.runScheduledTasks(maxHours, test.skipAfter, test.skip); |
314 | 314 |
315 let skipAddendum = (typeof test.skip != "number" ? "" : " skipping " + tes
t.skip + " hours after " + test.skipAfter + " hours"); | 315 let skipAddendum = (typeof test.skip != "number" ? "" : " skipping " + tes
t.skip + " hours after " + test.skipAfter + " hours"); |
316 deepEqual(requests, test.requests, "Requests with Math.random() returning
" + randomResult + skipAddendum); | 316 deepEqual(requests, test.requests, "Requests with Math.random() returning
" + randomResult + skipAddendum); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 equal(texts.message, "fr"); | 403 equal(texts.message, "fr"); |
404 }); | 404 }); |
405 | 405 |
406 test("Missing translation", function() | 406 test("Missing translation", function() |
407 { | 407 { |
408 let notification = {message: {"en-US": "en-US"}}; | 408 let notification = {message: {"en-US": "en-US"}}; |
409 let texts = Notification.getLocalizedTexts(notification, "fr"); | 409 let texts = Notification.getLocalizedTexts(notification, "fr"); |
410 equal(texts.message, "en-US"); | 410 equal(texts.message, "en-US"); |
411 }); | 411 }); |
412 })(); | 412 })(); |
OLD | NEW |