@@ -67,14 +67,19 @@ async function waitForReadyToRegister() {
67
67
} ;
68
68
69
69
it ( 'sets the registration options' , async ( ) => {
70
- await configTestBed ( { enabled : true , scope : 'foo' , updateViaCache : 'all' } ) ;
70
+ await configTestBed ( { enabled : true , scope : 'foo' , updateViaCache : 'all' , type : 'classic' } ) ;
71
71
72
72
expect ( TestBed . inject ( SwRegistrationOptions ) ) . toEqual ( {
73
73
enabled : true ,
74
74
scope : 'foo' ,
75
75
updateViaCache : 'all' ,
76
+ type : 'classic' ,
77
+ } ) ;
78
+ expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
79
+ scope : 'foo' ,
80
+ updateViaCache : 'all' ,
81
+ type : 'classic' ,
76
82
} ) ;
77
- expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , { scope : 'foo' , updateViaCache : 'all' } ) ;
78
83
} ) ;
79
84
80
85
it ( 'can disable the SW' , async ( ) => {
@@ -91,6 +96,7 @@ async function waitForReadyToRegister() {
91
96
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
92
97
scope : undefined ,
93
98
updateViaCache : undefined ,
99
+ type : undefined ,
94
100
} ) ;
95
101
} ) ;
96
102
@@ -101,6 +107,18 @@ async function waitForReadyToRegister() {
101
107
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
102
108
scope : undefined ,
103
109
updateViaCache : 'imports' ,
110
+ type : undefined ,
111
+ } ) ;
112
+ } ) ;
113
+
114
+ it ( 'can set type' , async ( ) => {
115
+ await configTestBed ( { enabled : true , type : 'module' } ) ;
116
+
117
+ expect ( TestBed . inject ( SwUpdate ) . isEnabled ) . toBe ( true ) ;
118
+ expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
119
+ scope : undefined ,
120
+ updateViaCache : undefined ,
121
+ type : 'module' ,
104
122
} ) ;
105
123
} ) ;
106
124
@@ -111,6 +129,7 @@ async function waitForReadyToRegister() {
111
129
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
112
130
scope : undefined ,
113
131
updateViaCache : undefined ,
132
+ type : undefined ,
114
133
} ) ;
115
134
} ) ;
116
135
@@ -155,17 +174,24 @@ async function waitForReadyToRegister() {
155
174
} ;
156
175
157
176
it ( 'sets the registration options (and overwrites those set via `provideServiceWorker()`' , async ( ) => {
158
- configTestBed ( { enabled : true , scope : 'provider' , updateViaCache : 'imports' } ) ;
177
+ configTestBed ( {
178
+ enabled : true ,
179
+ scope : 'provider' ,
180
+ updateViaCache : 'imports' ,
181
+ type : 'module' ,
182
+ } ) ;
159
183
await untilStable ( ) ;
160
184
expect ( TestBed . inject ( SwRegistrationOptions ) ) . toEqual ( {
161
185
enabled : true ,
162
186
scope : 'provider' ,
163
187
updateViaCache : 'imports' ,
188
+ type : 'module' ,
164
189
} ) ;
165
190
await waitForReadyToRegister ( ) ;
166
191
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
167
192
scope : 'provider' ,
168
193
updateViaCache : 'imports' ,
194
+ type : 'module' ,
169
195
} ) ;
170
196
} ) ;
171
197
@@ -186,6 +212,7 @@ async function waitForReadyToRegister() {
186
212
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
187
213
scope : undefined ,
188
214
updateViaCache : undefined ,
215
+ type : undefined ,
189
216
} ) ;
190
217
} ) ;
191
218
@@ -198,6 +225,7 @@ async function waitForReadyToRegister() {
198
225
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
199
226
scope : undefined ,
200
227
updateViaCache : undefined ,
228
+ type : undefined ,
201
229
} ) ;
202
230
} ) ;
203
231
@@ -271,6 +299,7 @@ async function waitForReadyToRegister() {
271
299
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
272
300
scope : undefined ,
273
301
updateViaCache : undefined ,
302
+ type : undefined ,
274
303
} ) ;
275
304
} ) ) ;
276
305
@@ -281,6 +310,7 @@ async function waitForReadyToRegister() {
281
310
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
282
311
scope : undefined ,
283
312
updateViaCache : undefined ,
313
+ type : undefined ,
284
314
} ) ;
285
315
} ) ) ;
286
316
@@ -298,6 +328,7 @@ async function waitForReadyToRegister() {
298
328
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
299
329
scope : undefined ,
300
330
updateViaCache : undefined ,
331
+ type : undefined ,
301
332
} ) ;
302
333
} ) ) ;
303
334
@@ -308,6 +339,7 @@ async function waitForReadyToRegister() {
308
339
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
309
340
scope : undefined ,
310
341
updateViaCache : undefined ,
342
+ type : undefined ,
311
343
} ) ;
312
344
} ) ) ;
313
345
@@ -323,6 +355,7 @@ async function waitForReadyToRegister() {
323
355
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
324
356
scope : undefined ,
325
357
updateViaCache : undefined ,
358
+ type : undefined ,
326
359
} ) ;
327
360
} ) ) ;
328
361
@@ -340,6 +373,7 @@ async function waitForReadyToRegister() {
340
373
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
341
374
scope : undefined ,
342
375
updateViaCache : undefined ,
376
+ type : undefined ,
343
377
} ) ;
344
378
} ) ) ;
345
379
@@ -357,6 +391,7 @@ async function waitForReadyToRegister() {
357
391
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
358
392
scope : undefined ,
359
393
updateViaCache : undefined ,
394
+ type : undefined ,
360
395
} ) ;
361
396
} ) ) ;
362
397
@@ -366,6 +401,7 @@ async function waitForReadyToRegister() {
366
401
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
367
402
scope : undefined ,
368
403
updateViaCache : undefined ,
404
+ type : undefined ,
369
405
} ) ;
370
406
} ) ;
371
407
@@ -381,6 +417,7 @@ async function waitForReadyToRegister() {
381
417
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
382
418
scope : undefined ,
383
419
updateViaCache : undefined ,
420
+ type : undefined ,
384
421
} ) ;
385
422
} ) ) ;
386
423
@@ -397,6 +434,7 @@ async function waitForReadyToRegister() {
397
434
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
398
435
scope : undefined ,
399
436
updateViaCache : undefined ,
437
+ type : undefined ,
400
438
} ) ;
401
439
} ) ) ;
402
440
@@ -413,6 +451,7 @@ async function waitForReadyToRegister() {
413
451
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
414
452
scope : undefined ,
415
453
updateViaCache : undefined ,
454
+ type : undefined ,
416
455
} ) ;
417
456
} ) ) ;
418
457
@@ -429,6 +468,7 @@ async function waitForReadyToRegister() {
429
468
expect ( swRegisterSpy ) . toHaveBeenCalledWith ( 'sw.js' , {
430
469
scope : undefined ,
431
470
updateViaCache : undefined ,
471
+ type : undefined ,
432
472
} ) ;
433
473
} ) ) ;
434
474
0 commit comments