fix(service-worker): add missing annotation for SwPush (#19721)

PR Close #19721
This commit is contained in:
Trotyl 2017-10-16 18:08:41 +08:00 committed by Tobias Bosch
parent 9723a362b6
commit 15a8429b96
2 changed files with 24 additions and 3 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
@ -23,6 +24,7 @@ import {NgswCommChannel} from './low_level';
*
* @experimental
*/
@Injectable()
export class SwPush {
readonly messages: Observable<object>;
readonly subscription: Observable<PushSubscription|null>;
@ -79,4 +81,4 @@ export class SwPush {
const unsubscribeOnce = op_take.call(unsubscribe, 1);
return op_toPromise.call(unsubscribeOnce) as Promise<void>;
}
}
}

View File

@ -7,6 +7,7 @@
*/
import 'rxjs/add/operator/toPromise';
import {TestBed} from '@angular/core/testing';
import {NgswCommChannel} from '../src/low_level';
import {SwPush} from '../src/push';
@ -41,7 +42,7 @@ export function main() {
mock.setupSw();
});
});
describe('NgswPush', () => {
describe('SwPush', () => {
let push: SwPush;
let reg: MockServiceWorkerRegistration;
beforeEach((done: DoneFn) => {
@ -63,8 +64,17 @@ export function main() {
},
});
});
it('is injectable', () => {
TestBed.configureTestingModule({
providers: [
SwPush,
{provide: NgswCommChannel, useValue: comm},
]
});
expect(() => TestBed.get(SwPush)).not.toThrow();
});
});
describe('NgswUpdate', () => {
describe('SwUpdate', () => {
let update: SwUpdate;
let reg: MockServiceWorkerRegistration;
beforeEach((done: DoneFn) => {
@ -132,6 +142,15 @@ export function main() {
.then(() => done())
.catch(err => done.fail(err));
});
it('is injectable', () => {
TestBed.configureTestingModule({
providers: [
SwUpdate,
{provide: NgswCommChannel, useValue: comm},
]
});
expect(() => TestBed.get(SwUpdate)).not.toThrow();
});
});
});
}