To get it to work on Angular 2.1.1 I had to @Inject
window using a string
constructor( @Inject('Window') private window: Window) { }
and then mock it like this
beforeEach(() => {
let windowMock: Window = <any>{ };
TestBed.configureTestingModule({
providers: [
ApiUriService,
{ provide: 'Window', useFactory: (() => { return windowMock; }) }
]
});
and in the ordinary @NgModule
I provide it like this
{ provide: 'Window', useValue: window }