mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-28 15:28:15 +00:00
feat(browser.defer): flush should throw exception when queue is empty
This commit is contained in:
parent
d47ec772c3
commit
63cca9afbc
3 changed files with 7 additions and 1 deletions
2
src/angular-mocks.js
vendored
2
src/angular-mocks.js
vendored
|
|
@ -125,6 +125,8 @@ angular.module.ngMock.$Browser = function() {
|
||||||
} else {
|
} else {
|
||||||
if (self.deferredFns.length) {
|
if (self.deferredFns.length) {
|
||||||
self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
|
self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
|
||||||
|
} else {
|
||||||
|
throw Error('No deferred tasks to be flushed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
test/angular-mocksSpec.js
vendored
4
test/angular-mocksSpec.js
vendored
|
|
@ -291,6 +291,10 @@ describe('mocks', function() {
|
||||||
expect(browser.defer.now).toEqual(3);
|
expect(browser.defer.now).toEqual(3);
|
||||||
expect(log).toEqual('A;B;C;');
|
expect(log).toEqual('A;B;C;');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw an exception if there is nothing to be flushed', function() {
|
||||||
|
expect(function() {browser.defer.flush();}).toThrow('No deferred tasks to be flushed');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ describe('$defer', function() {
|
||||||
$browser.defer.flush();
|
$browser.defer.flush();
|
||||||
expect(counter).toBe(1);
|
expect(counter).toBe(1);
|
||||||
|
|
||||||
$browser.defer.flush(); //does nothing
|
expect(function() {$browser.defer.flush();}).toThrow('No deferred tasks to be flushed');
|
||||||
expect(counter).toBe(1);
|
expect(counter).toBe(1);
|
||||||
|
|
||||||
expect($exceptionHandler).not.toHaveBeenCalled();
|
expect($exceptionHandler).not.toHaveBeenCalled();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue