summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Myers <raydog87@gmail.com>2016-06-22 18:51:06 -0700
committerHubert Argasinski <argasinski.hubert@gmail.com>2016-06-29 18:38:51 -0400
commite2b466e6e7509909e4eccc0eba6a293f89b63a4f (patch)
treef818b2e98766d8c9d968c2c528a79e056925d4a0
parentf2cd951d15326de4a585b264d57189658109f757 (diff)
downloadasync-e2b466e6e7509909e4eccc0eba6a293f89b63a4f.tar.gz
Added test case to make sure that callback isn't called multiple times in asyncify
-rw-r--r--mocha_test/asyncify.js26
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);
+ });
});
});
});