When using Jasmine and Angular (1.4.7) with Restangular (1.4.0), httpBackend and angular-mocks (1.4.7), Chrome and PhantomJS both crash when encountering the following line:
httpBackend.whenGET('/something').respond(200);
If I get rid of it entirely, as below, I get the following error:
//httpBackend.whenGET('/something').respond(200);
scope.doSomething(); // will invoke a GET to /keepAlive
httpBackend.expectGET("/something").respond(200);
httpBackend.flush();
Error: Unexpected request: GET /something No more request expected
The code that it is testing is:
$scope.doSomething = function () {
Restangular.one('something').get();
};
I've tried everything I can think of. I'm down to the idea that this is just a bug in Karma/Jasmine/Restangular but I don't know how to work around it.
One thing worth noting is that httpBackend and Restangular disagree about the URL. Restangular adds the /
to /something
. httpBackend doesn't. This is why they don't match.
Aucun commentaire:
Enregistrer un commentaire