0
我收到以下錯誤(這是OK!)呼籲tohaveBeenCalledWith
時傳遞給另一個函數的函數:測試作爲參數在茉莉花
spy showError to have been called with [ '33' ] but actual calls were [ Function, 403 ]
有沒有什麼辦法可以測試功能調用函數用?
假設參數功能是testFun,如何測試如果應用
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');
}
}
感謝您的回覆。 假設參數函數是testFun,如何測試如果$ window.location.href hascorrect值施加 'code' 功能testFun(ErrorStatus中){ 開關(ErrorStatus中){ 箱401: $ window.location的。 href = url1; 休息; case 403: $ window.location.href = url2; 休息; 默認值: console.log('出錯了'); } } –
@PravinVarma這裏不可讀。請更新問題本身 – tanmay
@PravinVarma只是把'jasmine.any(函數)'放在你得到那個錯誤的參數中。這應該工作 – tanmay