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