diff options
| -rw-r--r-- | src/angular-mocks.js | 4 | ||||
| -rw-r--r-- | test/servicesSpec.js | 1 |
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); |
