mock's .xhr.flush() should throw exception when there is nothing to flush

This commit is contained in:
Igor Minar
2011-02-04 13:00:46 -08:00
parent 46d690ff01
commit 568574b915
2 changed files with 4 additions and 1 deletions

View File

@@ -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()();
}