angular/aio/src/app/sw-updates/global.value.spec.ts
Georgios Kalpakas 2ca6258a0f fix(aio): correctly reload page to apply ServiceWorker update (#16170)
Previously, due ot a limitation/bug in AoT compilation and `useValue`, the
`global` injected into `SwUpdateNotificationsService` was always undefined,
which prevented it from actually reloading the page after activating a
ServiceWorker update.

This commit fixes it by switching to `useFactory`, which works correctly with
AoT.
2017-04-19 22:33:58 -05:00

19 lines
374 B
TypeScript

import { ReflectiveInjector } from '@angular/core';
import { Global, globalProvider } from './global.value';
describe('Global', () => {
let value: any;
beforeEach(() => {
const injector = ReflectiveInjector.resolveAndCreate([globalProvider]);
value = injector.get(Global);
});
it('should be `window`', () => {
expect(value).toBe(window);
});
});