title: Jasmine SpyOn same method more than once
body: <p>I have an angular controller with a method that calls <code>$location.search()</code> twice.</p>
  
  <p>First time is just <code>$location.search()</code> to return the value.<br>
  Second time is <code>$location.search("foo", null)</code> to clear it.</p>
  
  <p>I have the following spy in my unit test:<br>
  <code>spyOn($location, "search").and.returnValue({ foo: "bar" });</code></p>
  
  <p>It appears the spy returns <code>{foo:"bar"}</code> even when my implementation does <code>$location.search("foo", null)</code>.</p>
  
  <p>I need a way to have two different spies for the same method depending on the arguments.</p>
  
  <p>I need this expect:<br>
  <code>expect($location.search().foo).toEqual(null);</code><br>
  to pass at the end of the unit test.</p>