jeudi 25 juin 2015

How does angular know that $httpBackend is replacing $http in angularjs tests?

I have a factory called myFactory that has as dependency $http. In my tests I want to mock this dependency. I found out that I could achieve it using $httpBackend. I did using the code below and it works. But I don't understand why. At what moment angular knows that httpBackend is in fact replacing the $http that is inside myFactory ?

beforeEach(inject(function(_myFactory_, _$httpBackend_){
    myFactory = _myFactory_;
    $httpBackend = _$httpBackend_;
}));

Aucun commentaire:

Enregistrer un commentaire