HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/elite/node_modules/waitress/test.js
var waitress = require('./index')
  , assert = require('assert');

describe('waitress', function() {
  it('should recieve an error', function() {
    assert.throws(function() {
      var done = waitress(3, function(err) {
        if (err) throw err;
      });

      done();
      done();
      done(new Error);
    });
  });

  it('should receive error from single callback', function() {
    assert.throws(function() {
      var done = waitress(1, function(err) {
        if (err) throw err;
      });

      done(new Error('hai tai mai shu'));
    }, /hai tai mai shu/);
  });

  it('should execute cb with zero count', function(next) {
    // for zero args
    var done = waitress(0, function(err, arr) {
      assert.ok(!err);
      assert.deepEqual(arr, []);
      next();
    });
  });

  it('should ignore false error param', function() {
    assert.doesNotThrow(function() {
      var done = waitress(3, function(err) {
        if (err) throw err;
      });

      done();
      done();
      done();
      done(false);
    });
  });

  it('should return last error', function() {
    assert.throws(function() {
      var done = waitress(3, function(err, results) {
        if (err) throw err;
      });

      done();
      done(new Error("nein nein nein"));
      done(new Error("no no no"));
    }, /no no no/);
  });

  it('should aggregate results', function() {
    (function() {
      var done = waitress(3, function(err, results) {
        if (err) throw err;
        assert.deepEqual(results, [1, 2, 3], "results aggregation wrong");
      });

      done(null, 1);
      done(null, 2);
      done(null, 3);
      done(null, 4);
    })();
  });

});