18
사용자가 단추를 클릭 할 때 내 서비스 상태를 검색 할 수있는 범위에 함수가 있거나 이벤트가 트리거되고이 함수가 자동으로 호출 될 때 이 있습니다. 나는에 다른 $ httpBackend 검사를 단위 테스트에서
describe('SendServiceCtrl', function(){
var scope, ctrl, $httpBackend, configuration;
beforeEach(function() {
module('papi', 'ngUpload');
});
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, config) {
configuration = config;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET(configuration.entrypoint + configuration.api + "/user/outboundstatus/").respond(200, {"meta":{"apiVersion":"0.1","code":200,"errors":null},"response":{"allowed":false}});
scope = $rootScope.$new();
ctrl = $controller('SendServiceCtrl', {$scope: scope});
}));
it('Should get the status', function() {
scope.serviceId = '09bb5943fa2881e1';
scope.getStatus();
$httpBackend.whenGET(configuration.entrypoint + configuration.api + '/outbound/service/' + scope.serviceId).respond(200, {"meta":{"apiVersion":"0.1","code":200,"errors":null}});
});
});
: 단위 테스트처럼 만들어
$scope.getStatus = function() {
$http({method: 'GET', url: config.entrypoint + config.api + '/outbound/service/' + $scope.serviceId})
.success(function(data) {
$scope.errorMessage = '';
$scope.serviceAllGood = data;
})
.error(function() {
$scope.serviceAllGood = '';
$scope.errorMessage = 'We are experiencing problems retrieving your service status.';
});
}
:
이것은 내가 사용하고있는 컨트롤러에 정의 된 내 기능입니다 같은 컨트롤러지만, 모두 다 잠깐 작동합니다. 내가 도대체 뭘 잘못하고있는 겁니까?
템플릿이이 오류를 발생시킵니다. – FlavorScape
'$ templateCache'를'ui.bootstrap'과 같이 사용하면 GET을 조롱 할 필요가 없다고 생각합니까? – domokun
@domokun 사용 된 곳으로 링크를 게시 할 수 있습니까? –