|
1 | 1 | /**
|
2 | 2 | * NOTE: We are in the process of migrating these tests to Mocha. If you are
|
3 |
| - * adding a new test, consider creating a new spec file in mocha_tests/ |
| 3 | + * adding a new test, please create a new spec file in mocha_tests/ |
4 | 4 | */
|
5 | 5 |
|
6 | 6 | require('babel-core/register');
|
@@ -392,154 +392,6 @@ exports['retry as an embedded task with interval'] = function(test) {
|
392 | 392 | });
|
393 | 393 | };
|
394 | 394 |
|
395 |
| -exports['waterfall'] = { |
396 |
| - |
397 |
| - 'basic': function(test){ |
398 |
| - test.expect(7); |
399 |
| - var call_order = []; |
400 |
| - async.waterfall([ |
401 |
| - function(callback){ |
402 |
| - call_order.push('fn1'); |
403 |
| - setTimeout(function(){callback(null, 'one', 'two');}, 0); |
404 |
| - }, |
405 |
| - function(arg1, arg2, callback){ |
406 |
| - call_order.push('fn2'); |
407 |
| - test.equals(arg1, 'one'); |
408 |
| - test.equals(arg2, 'two'); |
409 |
| - setTimeout(function(){callback(null, arg1, arg2, 'three');}, 25); |
410 |
| - }, |
411 |
| - function(arg1, arg2, arg3, callback){ |
412 |
| - call_order.push('fn3'); |
413 |
| - test.equals(arg1, 'one'); |
414 |
| - test.equals(arg2, 'two'); |
415 |
| - test.equals(arg3, 'three'); |
416 |
| - callback(null, 'four'); |
417 |
| - }, |
418 |
| - function(arg4, callback){ |
419 |
| - call_order.push('fn4'); |
420 |
| - test.same(call_order, ['fn1','fn2','fn3','fn4']); |
421 |
| - callback(null, 'test'); |
422 |
| - } |
423 |
| - ], function(err){ |
424 |
| - test.ok(err === null, err + " passed instead of 'null'"); |
425 |
| - test.done(); |
426 |
| - }); |
427 |
| -}, |
428 |
| - |
429 |
| - 'empty array': function(test){ |
430 |
| - async.waterfall([], function(err){ |
431 |
| - if (err) throw err; |
432 |
| - test.done(); |
433 |
| - }); |
434 |
| -}, |
435 |
| - |
436 |
| - 'non-array': function(test){ |
437 |
| - async.waterfall({}, function(err){ |
438 |
| - test.equals(err.message, 'First argument to waterfall must be an array of functions'); |
439 |
| - test.done(); |
440 |
| - }); |
441 |
| -}, |
442 |
| - |
443 |
| - 'no callback': function(test){ |
444 |
| - async.waterfall([ |
445 |
| - function(callback){callback();}, |
446 |
| - function(callback){callback(); test.done();} |
447 |
| - ]); |
448 |
| -}, |
449 |
| - |
450 |
| - 'async': function(test){ |
451 |
| - var call_order = []; |
452 |
| - async.waterfall([ |
453 |
| - function(callback){ |
454 |
| - call_order.push(1); |
455 |
| - callback(); |
456 |
| - call_order.push(2); |
457 |
| - }, |
458 |
| - function(callback){ |
459 |
| - call_order.push(3); |
460 |
| - callback(); |
461 |
| - }, |
462 |
| - function(){ |
463 |
| - test.same(call_order, [1,2,3]); |
464 |
| - test.done(); |
465 |
| - } |
466 |
| - ]); |
467 |
| -}, |
468 |
| - |
469 |
| - 'error': function(test){ |
470 |
| - test.expect(1); |
471 |
| - async.waterfall([ |
472 |
| - function(callback){ |
473 |
| - callback('error'); |
474 |
| - }, |
475 |
| - function(callback){ |
476 |
| - test.ok(false, 'next function should not be called'); |
477 |
| - callback(); |
478 |
| - } |
479 |
| - ], function(err){ |
480 |
| - test.equals(err, 'error'); |
481 |
| - }); |
482 |
| - setTimeout(test.done, 50); |
483 |
| -}, |
484 |
| - |
485 |
| - 'multiple callback calls': function(test){ |
486 |
| - var call_order = []; |
487 |
| - var arr = [ |
488 |
| - function(callback){ |
489 |
| - call_order.push(1); |
490 |
| - // call the callback twice. this should call function 2 twice |
491 |
| - callback(null, 'one', 'two'); |
492 |
| - callback(null, 'one', 'two'); |
493 |
| - }, |
494 |
| - function(arg1, arg2, callback){ |
495 |
| - call_order.push(2); |
496 |
| - callback(null, arg1, arg2, 'three'); |
497 |
| - }, |
498 |
| - function(arg1, arg2, arg3, callback){ |
499 |
| - call_order.push(3); |
500 |
| - callback(null, 'four'); |
501 |
| - }, |
502 |
| - function(/*arg4*/){ |
503 |
| - call_order.push(4); |
504 |
| - arr[3] = function(){ |
505 |
| - call_order.push(4); |
506 |
| - test.same(call_order, [1,2,2,3,3,4,4]); |
507 |
| - test.done(); |
508 |
| - }; |
509 |
| - } |
510 |
| - ]; |
511 |
| - async.waterfall(arr); |
512 |
| -}, |
513 |
| - |
514 |
| - 'call in another context': function(test) { |
515 |
| - if (isBrowser()) { |
516 |
| - // node only test |
517 |
| - test.done(); |
518 |
| - return; |
519 |
| - } |
520 |
| - |
521 |
| - var vm = require('vm'); |
522 |
| - var sandbox = { |
523 |
| - async: async, |
524 |
| - test: test |
525 |
| - }; |
526 |
| - |
527 |
| - var fn = "(" + (function () { |
528 |
| - async.waterfall([function (callback) { |
529 |
| - callback(); |
530 |
| - }], function (err) { |
531 |
| - if (err) { |
532 |
| - return test.done(err); |
533 |
| - } |
534 |
| - test.done(); |
535 |
| - }); |
536 |
| - }).toString() + "())"; |
537 |
| - |
538 |
| - vm.runInNewContext(fn, sandbox); |
539 |
| -} |
540 |
| - |
541 |
| -}; |
542 |
| - |
543 | 395 | exports['parallel'] = function(test){
|
544 | 396 | var call_order = [];
|
545 | 397 | async.parallel([
|
|
0 commit comments