我有一个角度控制器,其方法可以调用$location.search()两次.
第一次只是$location.search()返回值.
第二次是$location.search("foo", null)清除它.
我的单元测试中有以下间谍:
spyOn($location, "search").and.returnValue({ foo: "bar" });
{foo:"bar"}即使我的实施确实如此,间谍似乎也会回来$location.search("foo", null).
我需要一种方法,根据参数为同一个方法设置两个不同的间谍.
我需要这个期望:
expect($location.search().foo).toEqual(null);
在单元测试结束时通过.