diff --git a/aio/src/app/sw-updates/global.value.spec.ts b/aio/src/app/sw-updates/global.value.spec.ts new file mode 100644 index 0000000000..ff43fd55ef --- /dev/null +++ b/aio/src/app/sw-updates/global.value.spec.ts @@ -0,0 +1,18 @@ +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); + }); +}); diff --git a/aio/src/app/sw-updates/global.value.ts b/aio/src/app/sw-updates/global.value.ts index 58ff6b2562..91d1fe04a1 100644 --- a/aio/src/app/sw-updates/global.value.ts +++ b/aio/src/app/sw-updates/global.value.ts @@ -2,4 +2,7 @@ import { InjectionToken } from '@angular/core'; export const Global = new InjectionToken('global'); -export const globalProvider = { provide: Global, useValue: window }; +export const globalProvider = { provide: Global, useFactory: globalFactory }; +export function globalFactory() { + return window; +}