feat(aio): enable activating available ServiceWorker updates (#15561)
This commit is contained in:

committed by
Igor Minar

parent
67719f2185
commit
3ccbe28d9f
4
aio/src/testing/sw-update-notifications.service.ts
Normal file
4
aio/src/testing/sw-update-notifications.service.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export class MockSwUpdateNotificationsService {
|
||||
enable = jasmine.createSpy('MockSwUpdateNotificationsService.enable');
|
||||
disable = jasmine.createSpy('MockSwUpdateNotificationsService.disable');
|
||||
}
|
20
aio/src/testing/sw-updates.service.ts
Normal file
20
aio/src/testing/sw-updates.service.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import 'rxjs/add/operator/distinctUntilChanged';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
|
||||
export class MockSwUpdatesService {
|
||||
$$activateUpdateSubj = new Subject<boolean>();
|
||||
$$isUpdateAvailableSubj = new Subject<boolean>();
|
||||
isUpdateAvailable = this.$$isUpdateAvailableSubj.distinctUntilChanged();
|
||||
|
||||
activateUpdate(): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
this.$$activateUpdateSubj
|
||||
// Better simulate what actually happens with the real ServiceWorker.
|
||||
.take(1)
|
||||
.do(() => this.$$isUpdateAvailableSubj.next(false))
|
||||
.subscribe(resolve);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user