fix(mock.$httpBackend): resetExpectations should not create new array

This commit is contained in:
Vojta Jina 2012-01-10 23:08:30 -08:00
parent 5143e7bf06
commit c6ea1be053
2 changed files with 17 additions and 2 deletions

View file

@ -723,8 +723,8 @@ angular.mock.$httpBackendDecorator = function($delegate, $defer) {
}; };
$httpBackend.resetExpectations = function() { $httpBackend.resetExpectations = function() {
expectations = []; expectations.length = 0;
responses = []; responses.length = 0;
}; };
return $httpBackend; return $httpBackend;

View file

@ -780,6 +780,21 @@ describe('mocks', function() {
expect(callback).toHaveBeenCalledOnce(); expect(callback).toHaveBeenCalledOnce();
expect(cancelledClb).not.toHaveBeenCalled(); expect(cancelledClb).not.toHaveBeenCalled();
}); });
it('should not remove definitions', function() {
var cancelledClb = jasmine.createSpy('cancelled');
hb.when('GET', '/url').respond(200, 'success');
hb('GET', '/url', null, cancelledClb);
hb.resetExpectations();
hb('GET', '/url', null, callback, {});
hb.flush();
expect(callback).toHaveBeenCalledOnce();
expect(cancelledClb).not.toHaveBeenCalled();
});
}); });