feat(aio): enable activating available ServiceWorker updates (#15561)

This commit is contained in:
George Kalpakas
2017-03-30 09:55:03 +03:00
committed by Igor Minar
parent 67719f2185
commit 3ccbe28d9f
10 changed files with 636 additions and 3 deletions

View File

@ -0,0 +1,4 @@
export class MockSwUpdateNotificationsService {
enable = jasmine.createSpy('MockSwUpdateNotificationsService.enable');
disable = jasmine.createSpy('MockSwUpdateNotificationsService.disable');
}

View 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);
});
}
}