0
私はジャスミンとカルマで私のangularjsコントローラをテストしようとしていますが、スイートアラート機能のテストコードブロックはできません。私のテストクラスから$ scope.getCategory()が呼び出されたかどうかをテストするにはどうすればよいでしょうか?ここに私のコントローラとジャスミンのテストケースのコード例があります。ジャスミンテストでsweetalertを使用したAngularJsユニットテストコントローラ
コントローラー:
$scope.changeCategoryStatus = function(selectedId, selectedActive, topId) {
sweet.show({
title : "Kategoriyi "+(!selectedActive ? 'aktif' : 'pasif')+ " hale getirmek istiyor musunuz?",
type : "warning",
showCancelButton : true,
confirmButtonColor : "#DD6B55",
confirmButtonText : "Evet, değiştir!",
closeOnConfirm : false,
showLoaderOnConfirm : true,
html : false
}, function() {
$http({
method : "POST",
url : webRootUrl+"ajax/category/setActivation",
data : {
"id" : selectedId,
"active" : !selectedActive
}
}).then(function(response) {
//console.log(JSON.stringify(response.data))
if(response.data.outPutDouble==-7){
swal("Değiştirilemedi!", response.data.outPutString,"error");
}else{
$scope.getCategory(topId);
swal("Bu kategorinin durumu değiştirildi","",
"success");
}
}, function myError(response) {
swal("Bu kategorinin durumu değiştirilemedi","","error");
//console.log("***aaa" + JSON.stringify(response))
});
});
}
ジャスミンテストケース:
it("changeCategoryStatus success", function() {
$scope.changeCategoryStatus(21,true,0)
spyOn($scope,'getCategory')
expect($scope.getCategory).toHaveBeenCalled(); });
誰が先に同様の問題がありましたか?事前におかげで助けてください。ここで