Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 73c1b12

Browse files
committed
Expose method $notification.requestPermission.
1 parent 9e8bbf3 commit 73c1b12

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

angular-notification.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,21 @@ function $notificationProvider() {
138138
});
139139
};
140140

141-
return function $notification(title, options) {
141+
/**
142+
* Create a new notification.
143+
*
144+
* @param {string} title
145+
* @param {options} options
146+
*/
147+
148+
function $notification(title, options) {
142149
return new NgNotification(title, options);
143-
};
150+
}
151+
152+
// Expose requestPermission on $notification.
153+
$notification.requestPermission = NgNotification.requestPermission;
154+
155+
return $notification;
144156
}
145157

146158
/**

test/angular-notification.js

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ describe('Notification provider', function () {
7272
expect($window.Notification.requestPermission).to.be.called;
7373
expect($window.Notification.permission).to.equal('granted');
7474
});
75+
76+
it('should be possible to request permission', function (done) {
77+
$notification.requestPermission()
78+
.then(function (permission) {
79+
expect(permission).to.equal('granted');
80+
done();
81+
});
82+
83+
$window.Notification.respondPermission('granted');
84+
});
7585
});
7686

7787
describe('#$on', function () {

0 commit comments

Comments
 (0)