!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/wincloud_gateway/node_modules/switchback/test/   drwxr-xr-x
Free 12.95 GB of 57.97 GB (22.35%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     usage.test.js (5.7 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var should = require('should');
var switchback = require('../lib');



// Set up event bus to provide access to callback/switchback handler outcomes
var Bus = function() {
  this.afterFixture = function(fixtureID, cbOutcome, fnToCall) {
    return Bus.once(fixtureID, function(_outcome) {
      // cbOutcome should be an empty object at this point (passed by reference)
      cbOutcome.args = _outcome.args;
      cbOutcome.ctx = _outcome.ctx;
      fnToCall();
    });
  };
};
util.inherits(Bus, EventEmitter);
Bus = new Bus();

// Fixtures
var fixtures = {

  fn: function() {
    // Sniff call/caller data from this callback function by emitting event on cbReporter
    Bus.emit('fn', {
      args: Array.prototype.slice.call(arguments),
      ctx: this
    });
  },
  handlers: {
    success: function(data) {},
    error: function(err) {}
  }
};


// Suites
describe('switchback(Function)', function() {

  var sb;
  var cb = fixtures.fn;

  it('should return a switchback', function() {
    sb = switchback(cb);
    sb.should.be.a.Function;
    (switchback.isSwitchback(sb)).should.be.ok;
  });



  describe('when calling returned switchback as sb(null, 14, 23),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb(null, 14, 23);
    });

    _testThatCallbackHasNoError(cbOutcome);
    _testThatOtherArgumentsExist(cbOutcome);
  });



  describe('when calling returned switchback as sb("some error", 14, 23),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb('some error', 14, 23);
    });

    _testThatCallbackHasError(cbOutcome);
    _testThatOtherArgumentsExist(cbOutcome);
  });



  describe('when calling returned switchback as sb.error("some error", 14, 23),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb.error('some error', 14, 23);
    });

    _testThatCallbackHasError(cbOutcome);
    _testThatOtherArgumentsExist(cbOutcome);
  });
  describe('when calling returned switchback as sb.error(),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb.error();
    });

    _testThatCallbackHasError(cbOutcome);
  });



  describe('when calling returned switchback as sb.success("should not be an error", 14, 23),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb.success('should not be an error', 14, 23);
    });

    _testThatCallbackHasNoError(cbOutcome);
    _testThatOtherArgumentsExist(cbOutcome);
  });
  describe('when calling returned switchback as sb.success(),', function() {
    var cbOutcome = {};
    _listenForCallback(cbOutcome, function() {
      sb.success();
    });

    _testThatCallbackHasNoError(cbOutcome);
  });
});


describe('when calling returned switchback as sb(err), where `err` has an "exit" property that matches a known exit', function() {
  it('should trigger the appropriate exit', function (done){
    function myFn(sb){
      sb = switchback(sb);
      var err = new Error('HEY I\'M A BIG SCARY ERROR');
      err.exit = 'foo';
      setTimeout(function (){
        sb(err);
      }, 50);
    }

    myFn({
      success: function (){
        return done(new Error('Should have triggered the `foo` handler'));
      },
      error: function (err){
        return done(new Error('Should have triggered the `foo` handler'));
      },
      foo: function (){
        return done();
      }
    });

  });
});


describe('when calling returned switchback as sb(err), where `err`\'s "exit" property DOES NOT match a known exit', function() {
  it('should trigger the error exit', function (done){
    function myFn(sb){
      sb = switchback(sb);
      var err = new Error('HEY I\'M A BIG SCARY ERROR');
      err.exit = 'bar';
      setTimeout(function (){
        return sb(err);
      }, 50);
    }

    myFn({
      success: function (){
        return done(new Error('Should have triggered the `error` handler, instead outcome was `success`'));
      },
      error: function (err){
        return done();
      },
      foo: function (){
        return done(new Error('Should have triggered the `error` handler, instead outcome was `foo`'));
      }
    });
  });
});



describe('switchback(Handlers)', function() {

});

describe('switchback(Function, Object)', function() {

});

describe('switchback(Handlers, Object)', function() {

});


describe('switchback(Function, Object, Object)', function() {

});

describe('switchback(Handlers, Object, Object)', function() {

});



// Helpers
function _testThatCallbackHasError(cbOutcome) {
  it('should NOT receive error argument in original cb function', function() {
    should(cbOutcome.args).be.ok;
    should(cbOutcome.ctx).be.ok;
    cbOutcome.args.should.be.an.Array;
    cbOutcome.args.length.should.be.above(0);
    should(cbOutcome.args[0]).be.ok;
  });
}

function _testThatCallbackHasNoError(cbOutcome) {
  it('should NOT receive error argument in original cb function', function() {
    should(cbOutcome.args).be.ok;
    should(cbOutcome.ctx).be.ok;
    cbOutcome.args.should.be.an.Array;
    should(cbOutcome.args[0]).not.be.ok;
  });
}

function _testThatOtherArgumentsExist(cbOutcome) {
  it('should receive the two subsequent arguments in original cb function', function() {
    should(cbOutcome.args).be.ok;
    should(cbOutcome.ctx).be.ok;
    cbOutcome.args.should.be.an.Array;
    cbOutcome.args.length.should.be.above(1);
    should(cbOutcome.args[1]).be.ok;
    should(cbOutcome.args[2]).be.ok;
  });
}

function _listenForCallback(cbOutcome, fnThatRunsCallback) {
  before(function(done) {
    // When callback fires, proceed
    Bus.afterFixture('fn', cbOutcome, done);
    fnThatRunsCallback();
  });
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]--