jeudi 29 octobre 2015

Testing if a promise is called from a controller unit-testing AngularJS

I am writing unit tests in AngularJS using karma and I would like to test the following controller whether is calling or not the service. I cant use spyOn because it is a promise and not a function. I don't want to test the service itself but I can't figure out how can I do it.

    $scope.deleteItem= function(itemId){
    service.deleteItem(itemId)
    .then(function(){
      $scope.info("Deleted");
      $scope.getData();
    }, function(data){
      $scope.critical('error');
    });
};

Aucun commentaire:

Enregistrer un commentaire