调用时,我得到以下错误(可以!)tohaveBeenCalledWith
:
spy showError to have been called with [ '33' ] but actual calls were [ Function, 403 ]
有没有什么办法可以测试函数调用与功能?
假设参数Function为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');
}
}
是的。您可以使用jasmine.any
引用文档示例:
expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));
希望对您有所帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句