Skip to content

Commit b8082d0

Browse files
committed
more tests
1 parent 2bc2fe8 commit b8082d0

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ See [contributing guide](.github/CONTRIBUTING.md)
108108

109109
| Date | Version | Description |
110110
| ----------- | ------- | ----------- |
111-
| 2017-03-09 | v1.2.8 | Maintenance |
111+
| 2017-03-09 | v1.2.9 | Maintenance |
112112
| 2017-01-22 | v1.2.0 | Split the internal web notification API into a new project: simple-web-notification |
113113
| 2017-01-13 | v1.0.26 | Maintenance |
114114
| 2016-11-23 | v1.0.19 | Use forked version of html5-desktop-notifications in order to resolve few issues |

angular-web-notification.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
*/
6868
var showNotification = webNotificationAPI.showNotification;
6969

70-
/*istanbul ignore else*/
7170
if (showNotification) {
7271
return webNotificationAPI;
7372
}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-web-notification",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "AngularJS service for displaying web notifications.",
55
"authors": [
66
"Sagie Gur-Ari <[email protected]>"

docs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Date | Version | Description |
22
| ----------- | ------- | ----------- |
3-
| 2017-03-09 | v1.2.8 | Maintenance |
3+
| 2017-03-09 | v1.2.9 | Maintenance |
44
| 2017-01-22 | v1.2.0 | Split the internal web notification API into a new project: simple-web-notification |
55
| 2017-01-13 | v1.0.26 | Maintenance |
66
| 2016-11-23 | v1.0.19 | Use forked version of html5-desktop-notifications in order to resolve few issues |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-web-notification",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "AngularJS service for displaying web notifications.",
55
"author": {
66
"name": "Sagie Gur-Ari",

test/spec/angular-web-notification-spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,21 @@ describe('angular-web-notification', function () {
2222

2323
beforeEach(window.angular.mock.module('angular-web-notification'));
2424

25-
beforeEach(inject(function (webNotification) {
26-
webNotification.allowRequest = true;
25+
it('library not defined test', inject(function ($injector) {
26+
var showNotification = window.webNotification.showNotification;
27+
delete window.webNotification.showNotification;
28+
29+
var errorDetected = false;
30+
try {
31+
$injector.get('webNotification').$get();
32+
} catch (error) {
33+
assert.isDefined(error);
34+
errorDetected = true;
35+
}
36+
37+
window.webNotification.showNotification = showNotification;
38+
39+
assert.isTrue(errorDetected);
2740
}));
2841

2942
it('init test', inject(function (webNotification) {
@@ -36,7 +49,9 @@ describe('angular-web-notification', function () {
3649
describe('allowed', function () {
3750
it('valid', function (done) {
3851
inject(function (webNotification) {
52+
webNotification.allowRequest = true;
3953
assert.isTrue(webNotification.lib.MOCK_NOTIFY);
54+
4055
window.Notification.setAllowed(function (title, options) {
4156
assert.equal(title, 'Example Notification');
4257
assert.deepEqual(options, {
@@ -56,7 +71,9 @@ describe('angular-web-notification', function () {
5671

5772
it('auto close', function (done) {
5873
inject(function (webNotification) {
74+
webNotification.allowRequest = true;
5975
assert.isTrue(webNotification.lib.MOCK_NOTIFY);
76+
6077
window.Notification.setAllowed(function (title, options) {
6178
assert.equal(title, 'Example Notification');
6279
assert.deepEqual(options, {
@@ -78,7 +95,9 @@ describe('angular-web-notification', function () {
7895

7996
it('first time permissions', function (done) {
8097
inject(function (webNotification) {
98+
webNotification.allowRequest = true;
8199
assert.isTrue(webNotification.lib.MOCK_NOTIFY);
100+
82101
window.Notification.setNotAllowed(function (title, options) {
83102
assert.equal(title, 'first time');
84103
assert.deepEqual(options, {
@@ -105,7 +124,9 @@ describe('angular-web-notification', function () {
105124
describe('not allowed', function () {
106125
it('not allowed', function (done) {
107126
inject(function (webNotification) {
127+
webNotification.allowRequest = true;
108128
assert.isTrue(webNotification.lib.MOCK_NOTIFY);
129+
109130
window.Notification.setNotAllowed();
110131

111132
webNotification.showNotification('not allowed', {}, function onShow(error, hide) {
@@ -117,6 +138,7 @@ describe('angular-web-notification', function () {
117138
it('not allowed and not allowed to ask permissions', function (done) {
118139
inject(function (webNotification) {
119140
assert.isTrue(webNotification.lib.MOCK_NOTIFY);
141+
120142
window.Notification.setNotAllowed();
121143
webNotification.allowRequest = false;
122144

0 commit comments

Comments
 (0)