Skip to content

Commit

Permalink
170 Promise#nodeify should not pass as an explicit argument to a Node…
Browse files Browse the repository at this point in the history
….js continuation callback
  • Loading branch information
Daniel Foley authored and petkaantonov committed Apr 9, 2014
1 parent 96e3230 commit 2dc17aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nodeify.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function thrower(r) {
function Promise$_successAdapter(val, receiver) {
var nodeback = this;
ASSERT(typeof nodeback == "function");
var ret = tryCatch2(nodeback, receiver, null, val);
var ret = val === void 0
? tryCatch1(nodeback, receiver, null)
: tryCatch2(nodeback, receiver, null, val);
if (ret === errorObj) {
async.invokeLater(thrower, void 0, ret.e);
}
Expand Down
9 changes: 9 additions & 0 deletions test/mocha/q_nodeify.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,16 @@ describe("nodeify", function () {
sinon.assert.calledOnce(spy);
sinon.assert.calledWith(spy, null, 10);
}, 100);
});

it("calls back with an undefined resolution", function (done) {
var spy = sinon.spy();
Q().nodeify(spy);
setTimeout(function(){
sinon.assert.calledOnce(spy);
sinon.assert.calledWithExactly(spy, null);
done();
}, 10);
});

it("calls back with an error", function () {
Expand Down

0 comments on commit 2dc17aa

Please sign in to comment.