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.hash;
However when I run a test which contains this code, it will fail.
It’d be great to utilise all the features of Window, but as I’m using PhantomJs, I don’t think this is possible (I have also tried Chrome which yields the same results).
In AngularJs, I would have resorted to mocking $Window (or at least the properties in question), but as there is not a lot of documentation for Angular2 unit testing I’m not sure how to do this.
Can anyone help?