From 15a8429b96ce853968a96ef1f6c0b034504e9cb5 Mon Sep 17 00:00:00 2001 From: Trotyl Date: Mon, 16 Oct 2017 18:08:41 +0800 Subject: [PATCH] fix(service-worker): add missing annotation for SwPush (#19721) PR Close #19721 --- packages/service-worker/src/push.ts | 4 +++- packages/service-worker/test/comm_spec.ts | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/service-worker/src/push.ts b/packages/service-worker/src/push.ts index 25309d9379..e64bff11db 100644 --- a/packages/service-worker/src/push.ts +++ b/packages/service-worker/src/push.ts @@ -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; readonly subscription: Observable; @@ -79,4 +81,4 @@ export class SwPush { const unsubscribeOnce = op_take.call(unsubscribe, 1); return op_toPromise.call(unsubscribeOnce) as Promise; } -} \ No newline at end of file +} diff --git a/packages/service-worker/test/comm_spec.ts b/packages/service-worker/test/comm_spec.ts index e5abea51d6..299af592c6 100644 --- a/packages/service-worker/test/comm_spec.ts +++ b/packages/service-worker/test/comm_spec.ts @@ -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(); + }); }); }); }