diff --git a/src/js/__tests__/stores/sound-notification.js b/src/js/__tests__/stores/sound-notification.js index cedc6d5cc..51ea5347c 100644 --- a/src/js/__tests__/stores/sound-notification.js +++ b/src/js/__tests__/stores/sound-notification.js @@ -74,4 +74,12 @@ describe('Tests for SoundNotificationStore', function () { }); + it('Should reopen gitify when a notification is clicked', function () { + var nativeNotification = SoundNotificationStore.newNotification('Test', 'Hello, world!'); + + expect(nativeNotification.onclick.toString().indexOf('reopen-window') >= 0).toBe(true); + + nativeNotification.onclick(); + }); + }); diff --git a/src/js/stores/sound-notification.js b/src/js/stores/sound-notification.js index af37a6f11..f8d7c0f1a 100644 --- a/src/js/stores/sound-notification.js +++ b/src/js/stores/sound-notification.js @@ -17,6 +17,16 @@ var SoundNotificationStore = Reflux.createStore({ audio.play(); }, + newNotification: function (title, body) { + var nativeNotification = new Notification(title, { + body: body + }); + nativeNotification.onclick = function () { + ipc.sendChannel('reopen-window'); + }; + return nativeNotification; + }, + showNotification: function (countNew, response, latestNotification) { var title = (countNew == 1 ? 'Gitify - ' + latestNotification.full_name : @@ -24,12 +34,7 @@ var SoundNotificationStore = Reflux.createStore({ var body = (countNew == 1 ? latestNotification.subject : 'You\'ve got ' + countNew + ' notifications.'); - var nativeNotification = new Notification(title, { - body: body - }); - nativeNotification.onclick = function () { - ipc.sendChannel('reopen-window'); - }; + this.newNotification(title, body); }, onIsNewNotification: function (response) {