Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($q): $q.reject should forward callbacks if missing
Browse files Browse the repository at this point in the history
$q.reject('some reason').then() should not blow up, but correctly
forward the callbacks instead.

Closes #845
  • Loading branch information
IgorMinar committed Apr 2, 2012
1 parent 59fa40e commit c0b7847
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/q.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions test/ng/qSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)']);
});
});


Expand Down

0 comments on commit c0b7847

Please sign in to comment.