| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3124e42 commit 37710b9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | */ | |
| 8 | 8 | ||
| 9 | 9 | import {isPlatformBrowser} from '@angular/common'; | |
| 10 | - import {APP_INITIALIZER, ApplicationRef, ErrorHandler, InjectionToken, Injector, ModuleWithProviders, NgModule, NgZone, PLATFORM_ID} from '@angular/core'; | ||
| 10 | + import {APP_INITIALIZER, ApplicationRef, InjectionToken, Injector, ModuleWithProviders, NgModule, NgZone, PLATFORM_ID} from '@angular/core'; | ||
| 11 | 11 | import {merge, Observable, of} from 'rxjs'; | |
| 12 | 12 | import {delay, filter, take} from 'rxjs/operators'; | |
| 13 | 13 | ||
@@ -128,10 +128,9 @@ export function ngswAppInitializer( | |||
| 128 | 128 | const ngZone = injector.get(NgZone); | |
| 129 | 129 | ngZone.runOutsideAngular( | |
| 130 | 130 | () => readyToRegister$.pipe(take(1)).subscribe( | |
| 131 | - () => navigator.serviceWorker.register(script, {scope: options.scope}).catch(err => { | ||
| 132 | - const errorHandler = injector.get(ErrorHandler); | ||
| 133 | - errorHandler.handleError(err); | ||
| 134 | - }))); | ||
| 131 | + () => | ||
| 132 | + navigator.serviceWorker.register(script, {scope: options.scope}) | ||
| 133 | + .catch(err => console.error('Service worker registration failed with:', err)))); | ||
| 135 | 134 | }; | |
| 136 | 135 | return initializer; | |
| 137 | 136 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | * found in the LICENSE file at https://angular.io/license | |
| 7 | 7 | */ | |
| 8 | 8 | ||
| 9 | - import {ApplicationRef, ErrorHandler, PLATFORM_ID} from '@angular/core'; | ||
| 9 | + import {ApplicationRef, PLATFORM_ID} from '@angular/core'; | ||
| 10 | 10 | import {fakeAsync, flushMicrotasks, TestBed, tick} from '@angular/core/testing'; | |
| 11 | 11 | import {Subject} from 'rxjs'; | |
| 12 | 12 | import {filter, take} from 'rxjs/operators'; | |
@@ -21,7 +21,6 @@ describe('ServiceWorkerModule', () => { | |||
| 21 | 21 | return; | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | - let errorHandlerSpy: jasmine.Spy; | ||
| 25 | 24 | let swRegisterSpy: jasmine.Spy; | |
| 26 | 25 | ||
| 27 | 26 | const untilStable = () => { | |
@@ -35,14 +34,9 @@ describe('ServiceWorkerModule', () => { | |||
| 35 | 34 | ||
| 36 | 35 | describe('register()', () => { | |
| 37 | 36 | const configTestBed = async (opts: SwRegistrationOptions) => { | |
| 38 | - const errorHandler = {handleError: () => {}}; | ||
| 39 | - errorHandlerSpy = spyOn(errorHandler, 'handleError'); | ||
| 40 | 37 | TestBed.configureTestingModule({ | |
| 41 | 38 | imports: [ServiceWorkerModule.register('sw.js', opts)], | |
| 42 | - providers: [ | ||
| 43 | - {provide: ErrorHandler, useValue: errorHandler}, | ||
| 44 | - {provide: PLATFORM_ID, useValue: 'browser'}, | ||
| 45 | - ], | ||
| 39 | + providers: [{provide: PLATFORM_ID, useValue: 'browser'}], | ||
| 46 | 40 | }); | |
| 47 | 41 | ||
| 48 | 42 | await untilStable(); | |
@@ -77,10 +71,12 @@ describe('ServiceWorkerModule', () => { | |||
| 77 | 71 | }); | |
| 78 | 72 | ||
| 79 | 73 | it('catches and a logs registration errors', async () => { | |
| 74 | + const consoleErrorSpy = spyOn(console, 'error'); | ||
| 80 | 75 | swRegisterSpy.and.returnValue(Promise.reject('no reason')); | |
| 81 | 76 | ||
| 82 | 77 | await configTestBed({enabled: true, scope: 'foo'}); | |
| 83 | - expect(errorHandlerSpy).toHaveBeenCalledWith('no reason'); | ||
| 78 | + expect(consoleErrorSpy) | ||
| 79 | + .toHaveBeenCalledWith('Service worker registration failed with:', 'no reason'); | ||
| 84 | 80 | }); | |
| 85 | 81 | }); | |
| 86 | 82 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments