mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-20 00:10:26 +00:00
fix($q): $q.reject should forward callbacks if missing
$q.reject('some reason').then() should not blow up, but correctly
forward the callbacks instead.
Closes #845
This commit is contained in:
parent
59fa40ec0e
commit
c0b78478a0
2 changed files with 9 additions and 1 deletions
|
|
@ -274,7 +274,7 @@ function qFactory(nextTick, exceptionHandler) {
|
|||
then: function(callback, errback) {
|
||||
var result = defer();
|
||||
nextTick(function() {
|
||||
result.resolve(errback(reason));
|
||||
result.resolve((errback || defaultErrback)(reason));
|
||||
});
|
||||
return result.promise;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,6 +480,14 @@ describe('q', function() {
|
|||
syncResolve(deferred, rejectedPromise);
|
||||
expect(log).toEqual(['error(Error: not gonna happen)']);
|
||||
});
|
||||
|
||||
|
||||
it('should return a promise that forwards callbacks if the callbacks are missing', function() {
|
||||
var rejectedPromise = q.reject('rejected');
|
||||
promise.then(success(), error());
|
||||
syncResolve(deferred, rejectedPromise.then());
|
||||
expect(log).toEqual(['error(rejected)']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue