mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
mock's .xhr.flush() should throw exception when there is nothing to flush
This commit is contained in:
4
src/angular-mocks.js
vendored
4
src/angular-mocks.js
vendored
@@ -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()();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user