From 568574b915086bcb1f08e3f8903ef79497c97435 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 4 Feb 2011 13:00:46 -0800 Subject: mock's .xhr.flush() should throw exception when there is nothing to flush --- src/angular-mocks.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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()(); } -- cgit v1.2.3