i want to cover this dialogcontroller but it is not called in js file ,how to the testing for this ..please help.mddialog is injected dialogcontroller is also injected in the controller .
function DialogController($rootScope,$scope, $mdDialog,DeviceService,$state) { $scope.deviceData = $rootScope.deviceData;
$scope.count = 0;
$scope.iorAppsForm = {};
$scope.contextPath = location.href.replace(location.origin, "").split("/")[1];
$scope.checked= true;
$scope.initialLoad = false;
$scope.isdisable=false;
$scope.isDisabled = true;
$scope.hidebutton = true;
$scope.test= true;
$scope.currentCondition = "";
if($scope.deviceData.ProvMode == 'ACTIVE'){
$scope.deviceData.DeviceAttributeMap = $scope.deviceData.DeviceAttributeMap || {};
if($scope.deviceData.DeviceAttributeMap && $scope.deviceData.DeviceAttributeMap.IOR_STATUS){
$scope.deviceData.DeviceAttributeMap.IOR_STATUS = $scope.deviceData.DeviceAttributeMap.IOR_STATUS;
}else{
$scope.deviceData.DeviceAttributeMap.IOR_STATUS = {};
}
$scope.currentCondition = 'Active';
}else if($scope.deviceData.ProvMode == 'INACTIVE'){
if($scope.deviceData.DeviceType == 'IVG'){
$scope.currentCondition = 'InactiveIVG'
}else{
//localStorage.setItem("UserProfileType","E");
$scope.profilType = localStorage.getItem("UserProfileType");
if($scope.profilType == 'E'){
$scope.currentCondition = 'InactiveNoIVGExt';
}else if($scope.profilType == 'I'){
$scope.currentCondition = 'InactiveNoIVGInt';
}
}
}else if($scope.deviceData.ProvMode == 'PENDING_ACTIVATION'){
$scope.currentCondition = 'PendingActivationNew';
setTimeout(function(){
console.log("calling");
DeviceService.getDeviceStatus($scope.deviceData.DeviceGuid)
.then(function(response){
var data = JSON.parse(response);
console.log(data);
var status = '';
if(data.DEVICE_ACTIVATION == 'SENT'){
status= 'PendingActivationSent'
}else{
status = 'PendingActivationNew'
}
$scope.$apply(function () {
$scope.currentCondition = status;
});
});
},2000);
}
if($scope.currentCondition!=""){
$scope.initialLoad = true;
}
$scope.cancel = function(){
$mdDialog.hide();
};
$scope.closeDialog = function(){
ctrl.devices = $rootScope.resetDevice;
$mdDialog.cancel();
};
$scope.sendIORStatus = function () {
$scope.deviceData.DeviceAttributes = $scope.deviceData.DeviceAttributes || [];
var iorData = getJsonObject($scope.deviceData.DeviceAttributes,'AttrName','IOR_STATUS');
iorData.DeviceGuid = $scope.deviceData.DeviceGuid;
iorData.AttrName = 'IOR_STATUS';
iorData.AttrValueString = JSON.stringify($scope.deviceData.DeviceAttributeMap.IOR_STATUS);
$scope.deviceData.DeviceAttributes.push(iorData);
DeviceService.updateIORStatus($scope.deviceData)
.then(function(response){
console.log(response);
if(response == ''){
$mdDialog.cancel();
$state.reload();
}
});
};
};
};
}
})();
Aucun commentaire:
Enregistrer un commentaire