mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
mock's .xhr.flush() should throw exception when there is nothing to flush
This commit is contained in:
parent
46d690ff01
commit
568574b915
2 changed files with 4 additions and 1 deletions
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()();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue