【发布时间】:2016-07-12 01:32:01
【问题描述】:
我有一个角度控制器,其方法调用$location.search() 两次。
第一次只是$location.search()返回值。
第二次是$location.search("foo", null)清除它。
我的单元测试中有以下间谍:spyOn($location, "search").and.returnValue({ foo: "bar" });
即使我的实现执行$location.search("foo", null),间谍似乎也会返回{foo:"bar"}。
我需要一种方法,根据参数为同一方法设置两个不同的间谍。
我需要这个期望:expect($location.search().foo).toEqual(null);
在单元测试结束时通过。
【问题讨论】:
标签: angularjs unit-testing jasmine