title: How to test $state.go in Karma
body: <p>I know there are a few <code>$state.go</code> unit test questions on here already, but none seem to work for me. I have simple controller logic which chooses a state. </p>
  
  <pre><code>if (true) {
      $state.go('home.default');
  } else {
      $state.go('home.new');
  }
  </code></pre>
  
  <p>In order to test which state is hit i've tried the following:</p>
  
  <pre><code>it('should return a state', function () {
      spyOn($state, 'go');
      $state.go('home.default');
      expect($state.go).toHaveBeenCalledWith('home.default');
  });
  </code></pre>
  
  <p>this always works because of the line <code>$state.go('home.default');</code> which basically makes the test redundant, because i'm just calling which state i want then testing it. I want to see which state the controller calls. </p>
  
  <p>I'd expect the test to be something like this: </p>
  
  <pre><code>it('should return a state', function () {
      spyOn($state, 'go');
      expect($state.go).toHaveBeenCalledWith('home.default');
  });
  </code></pre>
  
  <p>But this doesn't work because it isn't called even though i know in the controller it is, any suggestions?</p>