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

Unified Diff: test/notification.js

Issue 29370562: [adblockpluscore] Issue 4762 - Added "relentless" notification that shows up in intervals (Closed)
Patch Set: Added another testcase and fixed review comments Created Jan. 20, 2017, 9:19 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/notification.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/notification.js
diff --git a/test/notification.js b/test/notification.js
index 6e6ec9fc813193d8f36d880a86ed9fec01a5a8d4..4527c0a12bebfb44ae86392291c5b019fdc8dd2c 100644
--- a/test/notification.js
+++ b/test/notification.js
@@ -371,6 +371,59 @@ exports.testURLSpecificNotification = function(test)
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
+exports.testInterval = function(test)
+{
+ let relentless = {
+ id: 3,
+ type: "relentless",
+ interval: 100
+ };
+
+ registerHandler.call(this, [relentless]);
+ this.runScheduledTasks(1).then(() =>
+ {
+ test.deepEqual(showNotifications(), [relentless], "Relentless notifications are shown initially");
+ }).then(() =>
+ {
+ test.deepEqual(showNotifications(), [], "Relentless notifications are not shown before the interval");
+ }).then(() =>
+ {
+ // Date always returns a fixed time (see setupTimerAndXMLHttp) so we
+ // manipulate the shown data manually.
+ Prefs.notificationdata.shown[relentless.id] -= relentless.interval;
+ test.deepEqual(showNotifications(), [relentless], "Relentless notifications are shown after the interval");
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
+
+exports.testRelentlessNotification = function(test)
+{
+ let relentless = {
+ id: 3,
+ type: "relentless",
+ interval: 100,
+ urlFilters: ["foo.com$document", "bar.foo$document"]
+ };
+
+ registerHandler.call(this, [relentless]);
+ this.runScheduledTasks(1).then(() =>
+ {
+ test.deepEqual(showNotifications(), [], "Relentless notification is not shown without url");
Felix Dahlke 2017/01/20 09:51:37 Nit: "url" -> "URL"?
wspee 2017/01/20 10:26:13 Done.
+ test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notification is not shown to the wrong url");
Felix Dahlke 2017/01/20 09:51:36 Nit: "shown to the wrong url" -> "shown for a non-
wspee 2017/01/20 10:26:13 Done.
+ test.deepEqual(showNotifications("http://foo.com"), [relentless], "Relentless notification is shown to correct url");
Felix Dahlke 2017/01/20 09:51:37 Nit: "shown to correct url" "shown for a matching
wspee 2017/01/20 10:26:13 Done.
+ }).then(() =>
+ {
+ test.deepEqual(showNotifications("http://foo.com"), [], "Relentless notifications are not shown before the interval");
+ }).then(() =>
+ {
+ // Date always returns a fixed time (see setupTimerAndXMLHttp) so we
+ // manipulate the shown data manually.
+ Prefs.notificationdata.shown[relentless.id] -= relentless.interval;
+ test.deepEqual(showNotifications(), [], "Relentless notifications are not shown after the interval without url");
Felix Dahlke 2017/01/20 09:51:37 Nit: "url" -> "URL"?
wspee 2017/01/20 10:26:13 Done.
+ test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifications are not shown after the interval to the wrong url");
Felix Dahlke 2017/01/20 09:51:36 Nit: "to the wrong url" -> "for a non-matching URL
wspee 2017/01/20 10:26:13 Done.
+ test.deepEqual(showNotifications("http://bar.foo.com"), [relentless], "Relentless notifications are shown after the interval to the correct url");
Felix Dahlke 2017/01/20 09:51:37 Nit: "to the correct url" -> "for a matching URL"?
wspee 2017/01/20 10:26:13 Done.
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
+
exports.testGlobalOptOut = function(test)
{
Notification.toggleIgnoreCategory("*", true);
@@ -402,6 +455,10 @@ exports.testGlobalOptOut = function(test)
id: 2,
type: "critical"
};
+ let relentless = {
+ id: 3,
+ type: "relentless"
+ };
Notification.toggleIgnoreCategory("*", true);
registerHandler.call(this, [information]);
@@ -418,6 +475,13 @@ exports.testGlobalOptOut = function(test)
}).then(() =>
{
test.deepEqual(showNotifications(), [critical], "Critical notifications are not ignored");
+
+ Prefs.notificationdata = {};
+ registerHandler.call(this, [relentless]);
+ return this.runScheduledTasks(1);
+ }).then(() =>
+ {
+ test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not ignored");
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
« no previous file with comments | « lib/notification.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld