相关疑难解决方法(0)

Jasmine SpyOn不止一次使用同样的方法

我有一个角度控制器,其方法可以调用$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);
在单元测试结束时通过.

unit-testing jasmine angularjs

6
推荐指数
1
解决办法
4711
查看次数

标签 统计

angularjs ×1

jasmine ×1

unit-testing ×1