| OLD | NEW |
| 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 originalApplication; | 7 let originalApplication; |
| 8 let originalAddonVersion; | 8 let originalAddonVersion; |
| 9 let info = require("info"); | 9 let info = require("info"); |
| 10 | 10 |
| 11 module("Notification", | 11 module("Notification handling", |
| 12 { | 12 { |
| 13 setup: function() | 13 setup: function() |
| 14 { | 14 { |
| 15 testRunner = this; | 15 testRunner = this; |
| 16 | 16 |
| 17 preparePrefs.call(this); | 17 preparePrefs.call(this); |
| 18 setupVirtualTime.call(this, function(wrapTimer) | 18 setupVirtualTime.call(this, function(wrapTimer) |
| 19 { | 19 { |
| 20 let NotificationModule = getModuleGlobal("notification"); | 20 let NotificationModule = getModuleGlobal("notification"); |
| 21 NotificationModule.downloader._timer = wrapTimer(NotificationModule.down
loader._timer); | 21 NotificationModule.downloader._timer = wrapTimer(NotificationModule.down
loader._timer); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 message: {en: "Critical"}, | 203 message: {en: "Critical"}, |
| 204 maxVersion: "1.4" | 204 maxVersion: "1.4" |
| 205 }); | 205 }); |
| 206 | 206 |
| 207 registerHandler([information, critical]); | 207 registerHandler([information, critical]); |
| 208 testRunner.runScheduledTasks(1); | 208 testRunner.runScheduledTasks(1); |
| 209 | 209 |
| 210 deepEqual(Notification.getNextToShow(), information, "Critical notification
is ignored if maxVersion doesn't match"); | 210 deepEqual(Notification.getNextToShow(), information, "Critical notification
is ignored if maxVersion doesn't match"); |
| 211 deepEqual(Notification.getNextToShow(), null, "Critical notification still i
gnored even if no other notifications available"); | 211 deepEqual(Notification.getNextToShow(), null, "Critical notification still i
gnored even if no other notifications available"); |
| 212 }); | 212 }); |
| 213 |
| 214 module("Notification localization"); |
| 215 |
| 216 test("Language only", function() |
| 217 { |
| 218 let notification = {message: {en: "en"}}; |
| 219 let texts = Notification.getLocalizedTexts(notification, "en"); |
| 220 equal(texts.message, "en"); |
| 221 texts = Notification.getLocalizedTexts(notification, "en-GB"); |
| 222 equal(texts.message, "en"); |
| 223 }); |
| 224 |
| 225 test("Language and country", function() |
| 226 { |
| 227 let notification = {message: {en: "en", "en-GB": "en-GB"}}; |
| 228 let texts = Notification.getLocalizedTexts(notification, "en-GB"); |
| 229 equal(texts.message, "en-GB"); |
| 230 texts = Notification.getLocalizedTexts(notification, "en"); |
| 231 equal(texts.message, "en"); |
| 232 }); |
| 233 |
| 234 test("Missing translation", function() |
| 235 { |
| 236 let notification = {message: {en: "en"}}; |
| 237 let texts = Notification.getLocalizedTexts(notification, "fr"); |
| 238 equal(texts.message, "en"); |
| 239 }); |
| 213 })(); | 240 })(); |
| OLD | NEW |