@@ -29,15 +29,64 @@ describe('simple-web-notification', function () {
2929 window . webNotification . allowRequest = true ;
3030 } ) ;
3131
32- it ( 'init test' , function ( ) {
33- assert . isObject ( window . webNotification ) ;
34- assert . isTrue ( window . Notification . MOCK_NOTIFY ) ;
35- assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
32+ describe ( 'showNotification tests' , function ( ) {
33+ it ( 'window' , function ( ) {
34+ assert . isObject ( window . webNotification ) ;
35+ assert . isFunction ( window . webNotification . initWebNotificationFromContext ) ;
36+ assert . isFunction ( window . webNotification . showNotification ) ;
37+ assert . isTrue ( window . Notification . MOCK_NOTIFY ) ;
38+ assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
39+ } ) ;
40+
41+ it ( 'global' , function ( ) {
42+ var global = {
43+ Notification : window . Notification
44+ } ;
45+
46+ window . webNotification . initWebNotificationFromContext ( global ) ;
47+
48+ assert . isObject ( global . webNotification ) ;
49+ assert . isFunction ( global . webNotification . showNotification ) ;
50+ } ) ;
51+
52+ it ( 'define' , function ( ) {
53+ var global = {
54+ Notification : window . Notification
55+ } ;
56+
57+ window . define = function ( factory ) {
58+ var webNotification = factory ( ) ;
59+
60+ assert . isObject ( webNotification ) ;
61+ assert . isFunction ( webNotification . showNotification ) ;
62+
63+ delete window . define ;
64+ } ;
65+ window . define . amd = true ;
66+
67+ window . webNotification . initWebNotificationFromContext ( global ) ;
68+ } ) ;
69+
70+ it ( 'module' , function ( ) {
71+ var global = {
72+ Notification : window . Notification
73+ } ;
74+
75+ window . module = {
76+ exports : { }
77+ } ;
78+
79+ window . webNotification . initWebNotificationFromContext ( global ) ;
80+
81+ assert . isFunction ( window . module . exports . showNotification ) ;
82+
83+ delete window . module ;
84+ } ) ;
3685 } ) ;
3786
38- describe ( 'showNotification tests ' , function ( ) {
39- describe ( 'showNotification allowed tests ' , function ( ) {
40- it ( 'showNotification all info test ' , function ( done ) {
87+ describe ( 'showNotification' , function ( ) {
88+ describe ( 'allowed' , function ( ) {
89+ it ( 'all info' , function ( done ) {
4190 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
4291 window . Notification . setAllowed ( function ( title , options ) {
4392 assert . equal ( title , 'Example Notification' ) ;
@@ -55,7 +104,7 @@ describe('simple-web-notification', function () {
55104 } ) ;
56105 } ) ;
57106
58- it ( 'showNotification with auto close test ' , function ( done ) {
107+ it ( 'auto close' , function ( done ) {
59108 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
60109 window . Notification . setAllowed ( function ( title , options ) {
61110 assert . equal ( title , 'Example Notification' ) ;
@@ -75,7 +124,7 @@ describe('simple-web-notification', function () {
75124 } ) ;
76125 } ) ;
77126
78- it ( 'showNotification no params test ' , function ( done ) {
127+ it ( 'no params' , function ( done ) {
79128 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
80129 window . Notification . setAllowed ( emptyValuesValidation ) ;
81130
@@ -84,14 +133,14 @@ describe('simple-web-notification', function () {
84133 } ) ;
85134 } ) ;
86135
87- it ( 'showNotification no input test ' , function ( ) {
136+ it ( 'no input' , function ( ) {
88137 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
89138 window . Notification . setAllowed ( emptyValuesValidation ) ;
90139
91140 window . webNotification . showNotification ( ) ;
92141 } ) ;
93142
94- it ( 'showNotification too many args test ' , function ( done ) {
143+ it ( 'too many args' , function ( done ) {
95144 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
96145 window . Notification . setAllowed ( emptyValuesValidation ) ;
97146
@@ -104,7 +153,7 @@ describe('simple-web-notification', function () {
104153 } , 50 ) ;
105154 } ) ;
106155
107- it ( 'showNotification null info test ' , function ( done ) {
156+ it ( 'null info' , function ( done ) {
108157 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
109158 window . Notification . setAllowed ( emptyValuesValidation ) ;
110159
@@ -113,7 +162,7 @@ describe('simple-web-notification', function () {
113162 } ) ;
114163 } ) ;
115164
116- it ( 'showNotification no callback test ' , function ( done ) {
165+ it ( 'no callback' , function ( done ) {
117166 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
118167 window . Notification . setAllowed ( function ( title , options ) {
119168 assert . equal ( title , 'Example Notification' ) ;
@@ -131,7 +180,7 @@ describe('simple-web-notification', function () {
131180 setTimeout ( done , 50 ) ;
132181 } ) ;
133182
134- it ( 'showNotification no title test ' , function ( done ) {
183+ it ( 'no title' , function ( done ) {
135184 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
136185 window . Notification . setAllowed ( function ( title , options ) {
137186 assert . equal ( title , '' ) ;
@@ -148,7 +197,7 @@ describe('simple-web-notification', function () {
148197 } ) ;
149198 } ) ;
150199
151- it ( 'showNotification with no icon test ' , function ( done ) {
200+ it ( 'with no icon' , function ( done ) {
152201 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
153202 window . Notification . setAllowed ( function ( title , options ) {
154203 assert . equal ( title , 'Example Notification' ) ;
@@ -165,7 +214,7 @@ describe('simple-web-notification', function () {
165214 } ) ;
166215 } ) ;
167216
168- it ( 'showNotification no options test ' , function ( done ) {
217+ it ( 'no options' , function ( done ) {
169218 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
170219 window . Notification . setAllowed ( function ( title , options ) {
171220 assert . equal ( title , 'no options' ) ;
@@ -179,7 +228,7 @@ describe('simple-web-notification', function () {
179228 } ) ;
180229 } ) ;
181230
182- it ( 'showNotification first time permissions test ' , function ( done ) {
231+ it ( 'first time permissions' , function ( done ) {
183232 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
184233 window . Notification . setNotAllowed ( function ( title , options ) {
185234 assert . equal ( title , 'first time' ) ;
@@ -202,7 +251,7 @@ describe('simple-web-notification', function () {
202251 } ) ;
203252 } ) ;
204253
205- it ( 'showNotification with onClick' , function ( done ) {
254+ it ( 'onClick' , function ( done ) {
206255 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
207256 window . Notification . setAllowed ( function ( title , options ) {
208257 assert . equal ( title , 'Example Notification' ) ;
@@ -221,8 +270,8 @@ describe('simple-web-notification', function () {
221270 } ) ;
222271 } ) ;
223272
224- describe ( 'showNotification not allowed tests ' , function ( ) {
225- it ( 'showNotification not allowed test ' , function ( done ) {
273+ describe ( 'not allowed' , function ( ) {
274+ it ( 'not allowed' , function ( done ) {
226275 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
227276 window . Notification . setNotAllowed ( ) ;
228277
@@ -231,7 +280,7 @@ describe('simple-web-notification', function () {
231280 } ) ;
232281 } ) ;
233282
234- it ( 'showNotification not allowed and not allowed to ask permissions test ' , function ( done ) {
283+ it ( 'not allowed to ask permissions' , function ( done ) {
235284 assert . isTrue ( window . webNotification . lib . MOCK_NOTIFY ) ;
236285 window . Notification . setNotAllowed ( ) ;
237286 window . webNotification . allowRequest = false ;
0 commit comments