Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.137.174.52
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : 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,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/3/cwd/usr/lib/node_modules/npm/node_modules/retry/test/integration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/3/cwd/usr/lib/node_modules/npm/node_modules/retry/test/integration/test-retry-wrap.js
var common = require('../common');
var assert = common.assert;
var fake = common.fake.create();
var retry = require(common.dir.lib + '/retry');

function getLib() {
  return {
    fn1: function() {},
    fn2: function() {},
    fn3: function() {}
  };
}

(function wrapAll() {
  var lib = getLib();
  retry.wrap(lib);
  assert.equal(lib.fn1.name, 'bound retryWrapper');
  assert.equal(lib.fn2.name, 'bound retryWrapper');
  assert.equal(lib.fn3.name, 'bound retryWrapper');
}());

(function wrapAllPassOptions() {
  var lib = getLib();
  retry.wrap(lib, {retries: 2});
  assert.equal(lib.fn1.name, 'bound retryWrapper');
  assert.equal(lib.fn2.name, 'bound retryWrapper');
  assert.equal(lib.fn3.name, 'bound retryWrapper');
  assert.equal(lib.fn1.options.retries, 2);
  assert.equal(lib.fn2.options.retries, 2);
  assert.equal(lib.fn3.options.retries, 2);
}());

(function wrapDefined() {
  var lib = getLib();
  retry.wrap(lib, ['fn2', 'fn3']);
  assert.notEqual(lib.fn1.name, 'bound retryWrapper');
  assert.equal(lib.fn2.name, 'bound retryWrapper');
  assert.equal(lib.fn3.name, 'bound retryWrapper');
}());

(function wrapDefinedAndPassOptions() {
  var lib = getLib();
  retry.wrap(lib, {retries: 2}, ['fn2', 'fn3']);
  assert.notEqual(lib.fn1.name, 'bound retryWrapper');
  assert.equal(lib.fn2.name, 'bound retryWrapper');
  assert.equal(lib.fn3.name, 'bound retryWrapper');
  assert.equal(lib.fn2.options.retries, 2);
  assert.equal(lib.fn3.options.retries, 2);
}());

(function runWrappedWithoutError() {
  var callbackCalled;
  var lib = {method: function(a, b, callback) {
    assert.equal(a, 1);
    assert.equal(b, 2);
    assert.equal(typeof callback, 'function');
    callback();
  }};
  retry.wrap(lib);
  lib.method(1, 2, function() {
    callbackCalled = true;
  });
  assert.ok(callbackCalled);
}());

(function runWrappedSeveralWithoutError() {
  var callbacksCalled = 0;
  var lib = {
    fn1: function (a, callback) {
      assert.equal(a, 1);
      assert.equal(typeof callback, 'function');
      callback();
    },
    fn2: function (a, callback) {
      assert.equal(a, 2);
      assert.equal(typeof callback, 'function');
      callback();
    }
  };
  retry.wrap(lib, {}, ['fn1', 'fn2']);
  lib.fn1(1, function() {
    callbacksCalled++;
  });
  lib.fn2(2, function() {
    callbacksCalled++;
  });
  assert.equal(callbacksCalled, 2);
}());

(function runWrappedWithError() {
  var callbackCalled;
  var lib = {method: function(callback) {
    callback(new Error('Some error'));
  }};
  retry.wrap(lib, {retries: 1});
  lib.method(function(err) {
    callbackCalled = true;
    assert.ok(err instanceof Error);
  });
  assert.ok(!callbackCalled);
}());

Anon7 - 2022
AnonSec Team