From f160c2867a7e363934bb12f238e0b10e656408be Mon Sep 17 00:00:00 2001 From: Andrew Naylor Date: Sat, 18 Apr 2015 22:16:30 +0100 Subject: [PATCH] Allow setting badge to undefined --- lib/notification.js | 2 +- test/notification.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/notification.js b/lib/notification.js index a088923..0b9c3d9 100644 --- a/lib/notification.js +++ b/lib/notification.js @@ -48,7 +48,7 @@ Notification.prototype = { return this._badge; }, set badge(value) { - if (typeof value === "number") { + if (typeof value === "number" || value === undefined) { this._badge = value; } } diff --git a/test/notification.js b/test/notification.js index 81bb70b..431eb0b 100644 --- a/test/notification.js +++ b/test/notification.js @@ -56,6 +56,12 @@ describe("Notification", function() { expect(typeof note.badge).to.equal("number"); }); + it("can be set to undefined", function() { + note.badge = 5; + note.badge = undefined; + expect(note.badge).to.be.undefined; + }); + it("cannot be set to a string", function() { note.badge = "hello"; expect(note.badge).to.be.undefined;