I\'m building some unit tests for a service in Angular2.
Within my Service I have the following code:
var hash: string;
hash = this.window.location.h
After RC4 method provide()
its depracated, so the way to handle this after RC4 is:
let myMockWindow: Window;
beforeEach(() => {
myMockWindow = { location: {hash: 'WAOW-MOCK-HASH'}};
addProviders([SomeService, {provide: Window, useValue: myMockWindow}]);
});
It take me a while to figure it out, how it works.