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

View file

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