feat($http): broadcast $http.request event

This commit is contained in:
Vojta Jina 2011-10-31 12:03:09 -07:00 committed by Igor Minar
parent a4c8ac7126
commit 7b705df2b7
2 changed files with 11 additions and 0 deletions

View file

@ -343,6 +343,7 @@ function $HttpProvider() {
rawRequest = $httpBackend(cfg.method, cfg.url, data, done, headers, cfg.timeout);
}
$rootScope.$broadcast('$http.request', self);
$http.pendingRequests.push(self);
return this;
};

View file

@ -686,6 +686,16 @@ describe('$http', function() {
});
it('should broadcast $http.request', function() {
$httpBackend.when('GET').then(200);
scope.$on('$http.request', callback);
var xhrFuture = $http({method: 'GET', url: '/whatever'});
expect(callback).toHaveBeenCalledOnce();
expect(callback.mostRecentCall.args[1]).toBe(xhrFuture);
});
describe('transform', function() {
describe('request', function() {