HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
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/vhost/disk-apps/pwa.sports-crowd.com/node_modules/saucelabs/test/helpers/index.js
var nock  = require('nock');
var utils = require('../../lib/utils');

var extend  = utils.extend;
var replace = utils.replace;

function Nockle(base, config) {
  if (!(this instanceof Nockle)) {
    return new Nockle(base, config);
  }

  this.base   = base;
  this.config = extend({}, config);
}

Nockle.prototype.succeed = function (method, api, values, reply) {
  values = extend({}, this.config, values);
  return nock(replace(this.base, values))[method](replace(api, values))
    .reply(200, reply || {});
};

Nockle.prototype.fail = function (method, api, values, reply) {
  values = extend({}, this.config, values);
  return nock(replace(this.base, values))[method](replace(api, values))
    .reply(404, reply || { error: 'error' });
};

Nockle.prototype.get = function (api, values, reply) {
  return this.succeed('get', api, values, reply);
};

Nockle.prototype.post = function (api, values, reply) {
  return this.succeed('post', api, values, reply);
};

Nockle.prototype.put = function (api, values, reply) {
  return this.succeed('put', api, values, reply);
};

Nockle.prototype.delete = function (api, values, reply) {
  return this.succeed('delete', api, values, reply);
};

Nockle.prototype.failget = function (api, values, reply) {
  return this.fail('get', api, values, reply);
};

Nockle.prototype.failpost = function (api, values, reply) {
  return this.fail('post', api, values, reply);
};

Nockle.prototype.failput = function (api, values, reply) {
  return this.fail('put', api, values, reply);
};

Nockle.prototype.faildelete = function (api, values, reply) {
  return this.fail('delete', api, values, reply);
};

module.exports = function (chai) {
  chai.Nockle = Nockle;
};