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

fix($q): $q.reject should forward callbacks if missing #846

Merged
merged 1 commit into from
Apr 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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