Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 (function() | |
2 { | |
3 let originalApplication; | |
4 let originalAddonVersion; | |
5 let info = require("info"); | |
6 let {Notification} = require("notification"); | |
7 | |
8 module("Notification", | |
9 { | |
10 setup: function() | |
11 { | |
12 originalApplication = info.application; | |
13 info.application = "chrome"; | |
14 originalAddonVersion = info.addonVersion; | |
15 info.addonVersion = "1.4.1"; | |
16 Prefs.shownNotifications = null; | |
17 }, | |
18 teardown: function() | |
19 { | |
20 info.application = originalApplication; | |
21 info.addonVersion = originalAddonVersion; | |
22 } | |
23 }); | |
24 | |
25 test("Single notification", 1, function() | |
Wladimir Palant
2013/07/19 08:18:29
I would rather not specify the number of checks ex
Felix Dahlke
2013/07/19 14:30:40
Agreed, that was a misconception on my side. You a
| |
26 { | |
27 let information = { | |
28 timestamp: 1, | |
29 severity: "information", | |
30 message: {en: "Information"} | |
31 }; | |
32 let notification = Notification.getNextToShow([information]); | |
33 equal(notification, information); | |
34 }); | |
35 | |
36 test("Information and critical", 1, function() | |
37 { | |
38 let information = { | |
39 timestamp: 1, | |
40 severity: "information", | |
41 message: {en: "Information"} | |
42 }; | |
43 let critical = { | |
44 timestamp: 2, | |
45 severity: "critical", | |
46 message: {en: "Critical"} | |
47 }; | |
48 let notification = Notification.getNextToShow([information, critical]); | |
49 equal(notification, critical); | |
50 }); | |
51 | |
52 test("Different platforms", 1, function() | |
53 { | |
54 let information = { | |
55 timestamp: 1, | |
56 severity: "information", | |
57 message: {en: "Information"}, | |
58 platforms: ["chrome", "firefox"] | |
59 }; | |
60 let critical = { | |
61 timestamp: 2, | |
62 severity: "critical", | |
63 message: {en: "Critical"}, | |
64 platforms: ["firefox"] | |
65 }; | |
66 let notification = Notification.getNextToShow([information, critical]); | |
67 equal(notification, information); | |
68 }); | |
69 | |
70 test("Min version", 1, function() | |
71 { | |
72 let information = { | |
73 timestamp: 1, | |
74 severity: "information", | |
75 message: {en: "Information"}, | |
76 minVersion: "1.4" | |
77 }; | |
78 let critical = { | |
79 timestamp: 2, | |
80 severity: "critical", | |
81 message: {en: "Critical"}, | |
82 minVersion: "1.5" | |
83 }; | |
84 let notification = Notification.getNextToShow([information, critical]); | |
85 equal(notification, information); | |
86 }); | |
87 | |
88 test("Max version", 1, function() | |
89 { | |
90 let information = { | |
91 timestamp: 1, | |
92 severity: "information", | |
93 message: {en: "Information"}, | |
94 maxVersion: "1.5" | |
95 }; | |
96 let critical = { | |
97 timestamp: 2, | |
98 severity: "critical", | |
99 message: {en: "Critical"}, | |
100 maxVersion: "1.4" | |
101 }; | |
102 let notification = Notification.getNextToShow([information, critical]); | |
103 equal(notification, information); | |
104 }); | |
105 | |
106 test("Information notifications appear just once", 2, function() | |
107 { | |
108 let information = { | |
109 timestamp: 1, | |
110 severity: "information", | |
111 message: {en: "Information"} | |
112 }; | |
113 let notification = Notification.getNextToShow([information]); | |
114 equal(notification, information); | |
115 notification = Notification.getNextToShow([information]); | |
116 ok(!notification, "Notification shouldn't be shown twice"); | |
117 }); | |
118 | |
119 test("Critical notifications appear every time", 2, function() | |
120 { | |
121 let critical = { | |
122 timestamp: 1, | |
123 severity: "critical", | |
124 message: {en: "Critical"} | |
125 }; | |
126 let notification = Notification.getNextToShow([critical]); | |
127 equal(notification, critical); | |
128 notification = Notification.getNextToShow([critical]); | |
129 equal(notification, critical); | |
130 }); | |
131 })(); | |
OLD | NEW |