我在调用tohaveBeenCalledWith
时遇到错误(这是正常的!):
spy showError to have been called with [ '33' ] but actual calls were [ Function, 403 ]
我有没有办法测试功能函数调用?
假设参数函数是testFun ,如何测试$ window.location.href是否已应用正确的值
function testFun(errorStatus) {
switch (errorStatus) {
case 401:
$window.location.href = url1;
break;
case 403:
$window.location.href = url2;
break;
default:
console.log('Something went wrong');
}
}
答案 0 :(得分:1)
是。您可以使用jasmine.any
引用文档示例:
expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));
希望有所帮助!