aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2011-02-04 13:00:46 -0800
committerIgor Minar2011-02-04 14:11:52 -0800
commit568574b915086bcb1f08e3f8903ef79497c97435 (patch)
treed1cbd0997f97a1bd9ce0592cd919542984afc868
parent46d690ff0188836688811dda9af1b99c44750c48 (diff)
downloadangular.js-568574b915086bcb1f08e3f8903ef79497c97435.tar.bz2
mock's .xhr.flush() should throw exception when there is nothing to flush
-rw-r--r--src/angular-mocks.js4
-rw-r--r--test/servicesSpec.js1
2 files changed, 4 insertions, 1 deletions
diff --git a/src/angular-mocks.js b/src/angular-mocks.js
index 71a18d06..bbdcc94d 100644
--- a/src/angular-mocks.js
+++ b/src/angular-mocks.js
@@ -142,6 +142,10 @@ function MockBrowser() {
self.xhr.expectPUT = angular.bind(self, self.xhr.expect, 'PUT');
self.xhr.expectJSON = angular.bind(self, self.xhr.expect, 'JSON');
self.xhr.flush = function() {
+ if (requests.length == 0) {
+ throw new Error("No xhr requests to be flushed!");
+ }
+
while(requests.length) {
requests.pop()();
}
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index a081882d..70645caf 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -723,7 +723,6 @@ describe("service", function(){
$browserXhr.expectGET('/url').respond('ERROR');
cache('GET', '/url', null, callback);
$browser.defer.flush();
- $browserXhr.flush();
expect(log).toEqual('"first";"first";');
cache('GET', '/url', null, callback, false);