@@ -22,8 +22,21 @@ describe('angular-web-notification', function () {
22
22
23
23
beforeEach ( window . angular . mock . module ( 'angular-web-notification' ) ) ;
24
24
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 ) ;
27
40
} ) ) ;
28
41
29
42
it ( 'init test' , inject ( function ( webNotification ) {
@@ -36,7 +49,9 @@ describe('angular-web-notification', function () {
36
49
describe ( 'allowed' , function ( ) {
37
50
it ( 'valid' , function ( done ) {
38
51
inject ( function ( webNotification ) {
52
+ webNotification . allowRequest = true ;
39
53
assert . isTrue ( webNotification . lib . MOCK_NOTIFY ) ;
54
+
40
55
window . Notification . setAllowed ( function ( title , options ) {
41
56
assert . equal ( title , 'Example Notification' ) ;
42
57
assert . deepEqual ( options , {
@@ -56,7 +71,9 @@ describe('angular-web-notification', function () {
56
71
57
72
it ( 'auto close' , function ( done ) {
58
73
inject ( function ( webNotification ) {
74
+ webNotification . allowRequest = true ;
59
75
assert . isTrue ( webNotification . lib . MOCK_NOTIFY ) ;
76
+
60
77
window . Notification . setAllowed ( function ( title , options ) {
61
78
assert . equal ( title , 'Example Notification' ) ;
62
79
assert . deepEqual ( options , {
@@ -78,7 +95,9 @@ describe('angular-web-notification', function () {
78
95
79
96
it ( 'first time permissions' , function ( done ) {
80
97
inject ( function ( webNotification ) {
98
+ webNotification . allowRequest = true ;
81
99
assert . isTrue ( webNotification . lib . MOCK_NOTIFY ) ;
100
+
82
101
window . Notification . setNotAllowed ( function ( title , options ) {
83
102
assert . equal ( title , 'first time' ) ;
84
103
assert . deepEqual ( options , {
@@ -105,7 +124,9 @@ describe('angular-web-notification', function () {
105
124
describe ( 'not allowed' , function ( ) {
106
125
it ( 'not allowed' , function ( done ) {
107
126
inject ( function ( webNotification ) {
127
+ webNotification . allowRequest = true ;
108
128
assert . isTrue ( webNotification . lib . MOCK_NOTIFY ) ;
129
+
109
130
window . Notification . setNotAllowed ( ) ;
110
131
111
132
webNotification . showNotification ( 'not allowed' , { } , function onShow ( error , hide ) {
@@ -117,6 +138,7 @@ describe('angular-web-notification', function () {
117
138
it ( 'not allowed and not allowed to ask permissions' , function ( done ) {
118
139
inject ( function ( webNotification ) {
119
140
assert . isTrue ( webNotification . lib . MOCK_NOTIFY ) ;
141
+
120
142
window . Notification . setNotAllowed ( ) ;
121
143
webNotification . allowRequest = false ;
122
144
0 commit comments