Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 testRunner.runScheduledTasks(1); | 372 testRunner.runScheduledTasks(1); |
373 | 373 |
374 deepEqual(Notification.getNextToShow(), withoutURLFilter, "URL-specific noti fications are skipped"); | 374 deepEqual(Notification.getNextToShow(), withoutURLFilter, "URL-specific noti fications are skipped"); |
375 deepEqual(Notification.getNextToShow("http://foo.com"), withURLFilterFoo, "U RL-specific notification is retrieved"); | 375 deepEqual(Notification.getNextToShow("http://foo.com"), withURLFilterFoo, "U RL-specific notification is retrieved"); |
376 deepEqual(Notification.getNextToShow("http://foo.com"), null, "URL-specific notification is not retrieved"); | 376 deepEqual(Notification.getNextToShow("http://foo.com"), null, "URL-specific notification is not retrieved"); |
377 deepEqual(Notification.getNextToShow("http://www.example.com"), subdomainURL Filter, "URL-specific notification matches subdomain"); | 377 deepEqual(Notification.getNextToShow("http://www.example.com"), subdomainURL Filter, "URL-specific notification matches subdomain"); |
378 }); | 378 }); |
379 | 379 |
380 test("Global opt-out", function() | 380 test("Global opt-out", function() |
381 { | 381 { |
382 Notification.toggleIgnoreCategory("*", true); | |
383 ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enable g lobal opt-out"); | |
384 Notification.toggleIgnoreCategory("*", true); | |
385 ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enable g lobal opt-out (again)"); | |
386 Notification.toggleIgnoreCategory("*", false); | |
387 ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disable global opt-out"); | |
388 Notification.toggleIgnoreCategory("*", false); | |
389 ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disable global opt-out (again)"); | |
390 Notification.toggleIgnoreCategory("*"); | |
391 ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Toggle enable global opt-out"); | |
392 Notification.toggleIgnoreCategory("*"); | |
393 ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Toggle disable global opt-out"); | |
394 | |
382 Prefs.notifications_showui = false; | 395 Prefs.notifications_showui = false; |
383 | 396 Notification.toggleIgnoreCategory("*", false); |
397 ok(!Prefs.notifications_showui, "Opt-out UI will not be shown if global opt- out hasn't been enabled yet"); | |
384 Notification.toggleIgnoreCategory("*", true); | 398 Notification.toggleIgnoreCategory("*", true); |
385 | 399 ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling glob al opt-out"); |
386 ok(Prefs.notifications_showui, "Opt-out UI will be shown after opt-out"); | 400 Notification.toggleIgnoreCategory("*", false); |
401 ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling glob al opt-out even if it got disabled again"); | |
387 | 402 |
388 let information = fixConstructors({ | 403 let information = fixConstructors({ |
389 id: 1, | 404 id: 1, |
390 type: "information" | 405 type: "information" |
391 }); | 406 }); |
392 let critical = fixConstructors({ | 407 let critical = fixConstructors({ |
393 id: 2, | 408 id: 2, |
394 type: "critical" | 409 type: "critical" |
395 }); | 410 }); |
396 | 411 |
412 Notification.toggleIgnoreCategory("*", true); | |
397 registerHandler([information]); | 413 registerHandler([information]); |
398 testRunner.runScheduledTasks(1); | 414 testRunner.runScheduledTasks(1); |
399 | 415 |
400 deepEqual(Notification.getNextToShow(), null, "Information notifications are ignored"); | 416 deepEqual(Notification.getNextToShow(), null, "Information notifications are ignored after enabling global opt-out"); |
401 | 417 Notification.toggleIgnoreCategory("*", false); |
418 deepEqual(Notification.getNextToShow(), information, "Information notificati ons are shown after disabling global opt-out"); | |
419 | |
420 Notification.toggleIgnoreCategory("*", true); | |
402 Prefs.notificationdata = {}; | 421 Prefs.notificationdata = {}; |
403 registerHandler([critical]); | 422 registerHandler([critical]); |
404 testRunner.runScheduledTasks(1); | 423 testRunner.runScheduledTasks(1); |
405 | 424 |
406 deepEqual(Notification.getNextToShow(), critical, "Critical notifications ar e not ignored"); | 425 deepEqual(Notification.getNextToShow(), critical, "Critical notifications ar e not ignored"); |
Wladimir Palant
2015/05/26 11:23:19
This test is incomplete. Following scenarios need
Thomas Greiner
2015/05/28 13:24:18
Done, thanks for the additions.
Note that the exi
| |
407 }); | 426 }); |
408 | 427 |
409 module("Notification localization"); | 428 module("Notification localization"); |
410 | 429 |
411 test("Message without localization", function() | 430 test("Message without localization", function() |
412 { | 431 { |
413 let notification = {message: "non-localized"}; | 432 let notification = {message: "non-localized"}; |
414 let texts = Notification.getLocalizedTexts(notification, "en-US"); | 433 let texts = Notification.getLocalizedTexts(notification, "en-US"); |
415 equal(texts.message, "non-localized"); | 434 equal(texts.message, "non-localized"); |
416 }); | 435 }); |
(...skipping 16 matching lines...) Expand all Loading... | |
433 equal(texts.message, "fr"); | 452 equal(texts.message, "fr"); |
434 }); | 453 }); |
435 | 454 |
436 test("Missing translation", function() | 455 test("Missing translation", function() |
437 { | 456 { |
438 let notification = {message: {"en-US": "en-US"}}; | 457 let notification = {message: {"en-US": "en-US"}}; |
439 let texts = Notification.getLocalizedTexts(notification, "fr"); | 458 let texts = Notification.getLocalizedTexts(notification, "fr"); |
440 equal(texts.message, "en-US"); | 459 equal(texts.message, "en-US"); |
441 }); | 460 }); |
442 })(); | 461 })(); |
LEFT | RIGHT |