我已经使用Angular模态服务在我的angularjs Web应用程序中显示了弹出窗口。一旦涉及到单元测试,我该如何测试包含内部承诺的“ Angular Modal Service”部分。这里是我需要测试的代码部分。
我尝试了各种方法进行测试,但没有结果。
$scope.loadPatientsList = function() {
ModalService.showModal({
templateUrl: 'loading_message.html',
controller: "loadingPatientsController"
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$scope.test = "test";
if (result[0]) { // Handle success response from the REST call
if (result[1].length > 0) { // If patients are available
$scope.patients = result[1];
} else {
$scope.responsePopup(errorTxt, noPatient, 0);
}
} else { // Handle error response from the REST call
var error = result[1];
// Display error message if available
if (error.data.error_description.length > 0 || error.data.error_description !== undefined) {
$scope.responsePopup(errorTxt, error.data.error_description, 0);
} else {
$scope.responsePopup(errorTxt, networkError, 0);
}
}
});
});
};