Skip to content

Commit 3860f80

Browse files
Merge pull request #62 from JakeSidSmith/total-coverage
Total coverage
2 parents ec15749 + de5c9f2 commit 3860f80

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/js/__tests__/stores/sound-notification.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ describe('Tests for SoundNotificationStore', function () {
7474

7575
});
7676

77+
it('Should reopen gitify when a notification is clicked', function () {
78+
var nativeNotification = SoundNotificationStore.newNotification('Test', 'Hello, world!');
79+
80+
expect(nativeNotification.onclick.toString().indexOf('reopen-window') >= 0).toBe(true);
81+
82+
nativeNotification.onclick();
83+
});
84+
7785
});

src/js/stores/sound-notification.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,24 @@ var SoundNotificationStore = Reflux.createStore({
1717
audio.play();
1818
},
1919

20+
newNotification: function (title, body) {
21+
var nativeNotification = new Notification(title, {
22+
body: body
23+
});
24+
nativeNotification.onclick = function () {
25+
ipc.sendChannel('reopen-window');
26+
};
27+
return nativeNotification;
28+
},
29+
2030
showNotification: function (countNew, response, latestNotification) {
2131
var title = (countNew == 1 ?
2232
'Gitify - ' + latestNotification.full_name :
2333
'Gitify');
2434
var body = (countNew == 1 ?
2535
latestNotification.subject :
2636
'You\'ve got ' + countNew + ' notifications.');
27-
var nativeNotification = new Notification(title, {
28-
body: body
29-
});
30-
nativeNotification.onclick = function () {
31-
ipc.sendChannel('reopen-window');
32-
};
37+
this.newNotification(title, body);
3338
},
3439

3540
onIsNewNotification: function (response) {

0 commit comments

Comments
 (0)