aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVojta Jina2012-01-10 23:08:30 -0800
committerVojta Jina2012-01-11 11:48:03 -0800
commitc6ea1be0536b9d4564f028554fd1762feba58994 (patch)
treecd17e535796b45dfebda799b317eae0d0812e3d6
parent5143e7bf065a3cbdf8400cf095b653d51bc83b8f (diff)
downloadangular.js-c6ea1be0536b9d4564f028554fd1762feba58994.tar.bz2
fix(mock.$httpBackend): resetExpectations should not create new array
-rw-r--r--src/angular-mocks.js4
-rw-r--r--test/angular-mocksSpec.js15
2 files changed, 17 insertions, 2 deletions
diff --git a/src/angular-mocks.js b/src/angular-mocks.js
index 62a37763..9cc0db43 100644
--- a/src/angular-mocks.js
+++ b/src/angular-mocks.js
@@ -723,8 +723,8 @@ angular.mock.$httpBackendDecorator = function($delegate, $defer) {
};
$httpBackend.resetExpectations = function() {
- expectations = [];
- responses = [];
+ expectations.length = 0;
+ responses.length = 0;
};
return $httpBackend;
diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js
index d7f40bb2..248bb108 100644
--- a/test/angular-mocksSpec.js
+++ b/test/angular-mocksSpec.js
@@ -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();
+ });
});