0
나는 cloudant에 대한 후속 요청을하는 각도 코드 조각을 가지고 있으며, 응답을 리턴하고, 그것으로 URL을 만들고, 같은 요청을 받는다. get 요청은 프런트 엔드에서 렌더링 될 PDF 파일을 빌드 할 때 사용하는 배열 버퍼를 반환합니다.단위 테스트 자스민과 각도 Js
누군가가 휴식 테스트 API와 함께 단위 테스팅을하는 방법에 대한 조언을 해 줄 수 있습니까? 나를위한 새로운 영역입니다. PFB 내 코드
$scope.viewfile = function(name) {
$http({
method : 'POST',
url : '/search/searchFiles',
data : {'currentdropdownvalue' : name} ,
}).
success(function(data){
if (!angular.isUndefined(data.docs[0])){
$scope.file = data.docs[0]._id;
var fileUrl = $scope.cloudantUrl + $scope.file +"/"+ $scope.file;
$http.get(fileUrl {responseType:'arraybuffer'})
.success(function (response) {
var file = new Blob([response], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
$scope.content = $sce.trustAsResourceUrl(fileURL);
$scope.contentType = "application/pdf";
$scope.contentWords = null;
}).error(function(data){
console.log("Printing Error inside Post of view " , data);
});
}
else{
$scope.content = null;
$scope.contentWords = "File is not available for the selected Name";
}
}).
error(function(data){
console.log("Printing Error inside view " , data);
});
};
}
당신은 HTTP를을 조롱 $ httpBackend을 사용할 수 있습니다 내가 가진 것 내가 그 생각을 사용하고 – MatTaNg
은 당신이 모의 또는 일부 샘플을 게시하시기 바랍니다 수 호출 https://docs.angularjs.org/api/ngMock/service/$httpBackend 나는 $ httpBackend의 전문가와 거리가 멀다. 나는 보통 $ http 개체에 스파이를 넣고 기본적으로 똑같은 느낌을주는 물건을 반환합니다. 당신은 $ httpBackend를 사용하기로되어 있습니다. – user6591323
그것을 구축 할 수 있도록 – MatTaNg