summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2017-04-03 23:19:02 -0700
committerAlexander Early <alexander.early@gmail.com>2017-04-03 23:19:02 -0700
commit9b0f9eb1854cbc30960251a71ff8ce08bfa9dc0a (patch)
treed078ca0979b55a69a3f111f119adb92231cc5704
parenta6bd3a00b505e2bc51d6f322387645aff61abf76 (diff)
downloadasync-9b0f9eb1854cbc30960251a71ff8ce08bfa9dc0a.tar.gz
add a test for a unique waterfall fail case
-rw-r--r--mocha_test/waterfall.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/mocha_test/waterfall.js b/mocha_test/waterfall.js
index 0c21c80..54ca9f9 100644
--- a/mocha_test/waterfall.js
+++ b/mocha_test/waterfall.js
@@ -93,7 +93,6 @@ describe("waterfall", function () {
it('multiple callback calls', function(){
var arr = [
function(callback){
- // call the callback twice. this should call function 2 twice
callback(null, 'one', 'two');
callback(null, 'one', 'two');
},
@@ -106,6 +105,37 @@ describe("waterfall", function () {
}).to.throw(/already called/);
});
+ it('multiple callback calls (trickier) @nodeonly', function(done){
+
+ // do a weird dance to catch the async thrown error before mocha
+ var listeners = process.listeners('uncaughtException');
+ process.removeAllListeners('uncaughtException');
+ process.once('uncaughtException', function onErr(err) {
+ listeners.forEach(function(listener) {
+ process.on('uncaughtException', listener);
+ });
+ // can't throw errors in a uncaughtException handler, defer
+ setTimeout(checkErr, 0, err)
+ })
+
+ function checkErr(err) {
+ expect(err.message).to.match(/already called/);
+ done();
+ }
+
+ async.waterfall([
+ function(callback){
+ setTimeout(callback, 0, null, 'one', 'two');
+ setTimeout(callback, 10, null, 'one', 'two');
+ },
+ function(arg1, arg2, callback){
+ setTimeout(callback, 15, null, arg1, arg2, 'three');
+ }
+ ], function () {
+ throw new Error('should not get here')
+ });
+ });
+
it('call in another context @nycinvalid @nodeonly', function(done) {
var vm = require('vm');
var sandbox = {