diff options
author | Ray Myers <raydog87@gmail.com> | 2016-06-22 18:51:06 -0700 |
---|---|---|
committer | Ray Myers <raydog87@gmail.com> | 2016-06-22 18:51:06 -0700 |
commit | 3ef90dac66ca93566ad162765fe24a122cb639cf (patch) | |
tree | 7433527ba22efc7166113508e793ae470d9f5227 | |
parent | 066c3f193b36e8430c23762889306b9d6e0adf5c (diff) | |
download | async-3ef90dac66ca93566ad162765fe24a122cb639cf.tar.gz |
Added test case to make sure that callback isn't called multiple times in asyncify
-rw-r--r-- | mocha_test/asyncify.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mocha_test/asyncify.js b/mocha_test/asyncify.js index aae878e..025083a 100644 --- a/mocha_test/asyncify.js +++ b/mocha_test/asyncify.js @@ -74,6 +74,13 @@ describe('asyncify', function(){ 'rsvp' ]; + // Both Bluebird and native promises emit these events. We handle it because Bluebird + // will report these rejections to stderr if we don't, which is a great feature for + // normal cases, but not here, since we expect unhandled rejections: + process.on('unhandledRejection', function () { + // Ignore. + }); + names.forEach(function(name) { describe(name, function() { @@ -111,6 +118,25 @@ describe('asyncify', function(){ done(); }); }); + + it('callback error', function(done) { + var promisified = function(argument) { + return new Promise(function (resolve) { + resolve(argument + " resolved"); + }); + }; + var call_count = 0; + async.asyncify(promisified)("argument", function () { + call_count++; + if (call_count === 1) { + throw new Error("error in callback"); + } + }); + setTimeout(function () { + expect(call_count).to.equal(1); + done(); + }, 15); + }); }); }); }); |