Solicitud inesperada: GET No se esperan más solicitudes en $ httpBackend
Tengo una función en mi alcance para recuperar el estado de mi servicio cuando el usuario hace clic en un botón o cuando se activa algún evento y esta función se llama automáticamente.
Esta es mi función, definida en el controlador que estoy usando:
$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.';
});
}
La prueba unitaria se hace como:
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}});
});
});
En la prueba de la unidad también tengo otras pruebas $ httpBackend en el mismo controlador, pero todas funcionan de forma sencilla. ¿Qué estoy haciendo mal?