Commit 00ce187b authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Don't show browser notifications on pageload

closes #7211
parent c547e66e
......@@ -11,12 +11,8 @@ app.collections.Notifications = Backbone.Collection.extend({
timeout: 300000, // 5 minutes
initialize: function() {
this.pollNotifications();
setTimeout(function() {
setInterval(this.pollNotifications.bind(this), this.timeout);
}.bind(this), this.timeout);
this.fetch();
setInterval(this.pollNotifications.bind(this), this.timeout);
Diaspora.BrowserNotification.requestPermission();
},
......
describe("app.collections.Notifications", function() {
describe("initialize", function() {
it("calls pollNotifications", function() {
spyOn(app.collections.Notifications.prototype, "pollNotifications");
it("calls fetch", function() {
spyOn(app.collections.Notifications.prototype, "fetch");
new app.collections.Notifications();
expect(app.collections.Notifications.prototype.pollNotifications).toHaveBeenCalled();
expect(app.collections.Notifications.prototype.fetch).toHaveBeenCalled();
});
it("calls Diaspora.BrowserNotification.requestPermission", function() {
......@@ -23,6 +23,16 @@ describe("app.collections.Notifications", function() {
expect(target.unreadCount).toBe(0);
expect(target.unreadCountByType).toEqual({});
});
it("repeatedly calls pollNotifications", function() {
spyOn(app.collections.Notifications.prototype, "pollNotifications").and.callThrough();
var collection = new app.collections.Notifications();
expect(app.collections.Notifications.prototype.pollNotifications).not.toHaveBeenCalled();
jasmine.clock().tick(collection.timeout);
expect(app.collections.Notifications.prototype.pollNotifications).toHaveBeenCalledTimes(1);
jasmine.clock().tick(collection.timeout);
expect(app.collections.Notifications.prototype.pollNotifications).toHaveBeenCalledTimes(2);
});
});
describe("pollNotifications", function() {
......@@ -31,9 +41,9 @@ describe("app.collections.Notifications", function() {
});
it("calls fetch", function() {
spyOn(app.collections.Notifications.prototype, "fetch");
spyOn(this.target, "fetch");
this.target.pollNotifications();
expect(app.collections.Notifications.prototype.fetch).toHaveBeenCalled();
expect(this.target.fetch).toHaveBeenCalled();
});
it("doesn't call Diaspora.BrowserNotification.spawnNotification when there are no new notifications", function() {
......@@ -52,14 +62,6 @@ describe("app.collections.Notifications", function() {
this.target.trigger("finishedLoading");
expect(Diaspora.BrowserNotification.spawnNotification).toHaveBeenCalled();
});
it("refreshes after timeout", function() {
spyOn(app.collections.Notifications.prototype, "pollNotifications").and.callThrough();
this.target.pollNotifications();
expect(app.collections.Notifications.prototype.pollNotifications).toHaveBeenCalledTimes(1);
jasmine.clock().tick(2 * this.target.timeout);
expect(app.collections.Notifications.prototype.pollNotifications).toHaveBeenCalledTimes(2);
});
});
describe("fetch", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment