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 * found in the LICENSE file at https://angular.io/license
*/ */
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject'; import {Subject} from 'rxjs/Subject';
@ -23,6 +24,7 @@ import {NgswCommChannel} from './low_level';
* *
* @experimental * @experimental
*/ */
@Injectable()
export class SwPush { export class SwPush {
readonly messages: Observable<object>; readonly messages: Observable<object>;
readonly subscription: Observable<PushSubscription|null>; readonly subscription: Observable<PushSubscription|null>;

View File

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