mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(mock.$httpBackend): resetExpectations should not create new array
This commit is contained in:
parent
5143e7bf06
commit
c6ea1be053
2 changed files with 17 additions and 2 deletions
4
src/angular-mocks.js
vendored
4
src/angular-mocks.js
vendored
|
|
@ -723,8 +723,8 @@ angular.mock.$httpBackendDecorator = function($delegate, $defer) {
|
|||
};
|
||||
|
||||
$httpBackend.resetExpectations = function() {
|
||||
expectations = [];
|
||||
responses = [];
|
||||
expectations.length = 0;
|
||||
responses.length = 0;
|
||||
};
|
||||
|
||||
return $httpBackend;
|
||||
|
|
|
|||
15
test/angular-mocksSpec.js
vendored
15
test/angular-mocksSpec.js
vendored
|
|
@ -780,6 +780,21 @@ describe('mocks', function() {
|
|||
expect(callback).toHaveBeenCalledOnce();
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue