Unerwartete Anforderung: GET Bei $ httpBackend wird keine weitere Anforderung erwartet

Ich habe eine Funktion in meinem Bereich, um den Status meines Dienstes abzurufen, wenn der Benutzer auf eine Schaltfläche klickt oder wenn ein Ereignis ausgelöst wird und diese Funktion automatisch aufgerufen wird.

Dies ist meine Funktion, die in der von mir verwendeten Steuerung definiert ist:

$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.';
    });
  }

Der Komponententest wird wie folgt durchgeführt:

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}});

  });

});

Im Unit-Test habe ich auch andere $ httpBackend-Tests auf dem gleichen Controller, aber alle funktionieren nur ein bisschen. Was mache ich falsch?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage