title: How to test Location in angular 2 with karma+jasmine
body: <p>Angular 2 v.2.0.0 - TS + karma + jasmine.</p>
  
  <p>I test this function - back on click to previously page: </p>
  
  <pre><code> public isClick: boolean = false;
  
   public backClicked(location: Location): void {
          if (!this.isClick) {
              this.isClick = true;
              this.location.back();
          }
      }
  </code></pre>
  
  <p>And this is my test:</p>
  
  <pre><code>describe("NavBarComponent", () =&gt; {
      describe("function backClicked(): void", () =&gt; {
          let testNavBarComponent: NavBarComponent;
          let loc: Location;
          beforeEach(() =&gt; {
              testNavBarComponent = new NavBarComponent(null);
          });
          loc = jasmine.createSpyObj("Location", ["back"]);
          it ("It is backClicked() function test", () =&gt; {
              testNavBarComponent.backClicked(loc);
              expect(loc.back).toHaveBeenCalledTimes(1);
          });
      });
  });
  </code></pre>
  
  <p>After i run the test, i've got this error: <code>TypeError: Cannot read property 'back' of null</code>. Maybe problem with <code>createSpyObj</code>, or somethig else?</p>