{"size": 1253, "ext": "js", "max_stars_repo_path": "__mocks__/superagent.js", "max_stars_repo_name": "nibble2/spotify-web-api-node", "max_stars_repo_stars_event_min_datetime": "2015-01-03T14:24:01.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T21:33:40.000Z", "max_issues_repo_path": "__mocks__/superagent.js", "max_issues_repo_name": "nibble2/spotify-web-api-node", "max_issues_repo_issues_event_min_datetime": "2015-01-12T08:32:15.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-22T22:24:40.000Z", "max_forks_repo_path": "__mocks__/superagent.js", "max_forks_repo_name": "nibble2/spotify-web-api-node", "max_forks_repo_forks_event_min_datetime": "2015-01-11T21:15:04.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T06:34:42.000Z"}
{"max_stars_count": 2640, "max_issues_count": 394, "max_forks_count": 542, "avg_line_length": 15.2804878049, "max_line_length": 73, "alphanum_fraction": 0.5618515563}
'use strict';

//mock for superagent - __mocks__/superagent.js

var mockDelay;
var mockError;
var mockResponse = {
  status() {
    return 200;
  },
  ok() {
    return true;
  },
  get: jest.fn(),
  toError: jest.fn()
};

var Request = {
  put() {
    return this;
  },
  del() {
    return this;
  },
  post() {
    return this;
  },
  get() {
    return this;
  },
  send() {
    return this;
  },
  query() {
    return this;
  },
  field() {
    return this;
  },
  set() {
    return this;
  },
  accept() {
    return this;
  },
  timeout() {
    return this;
  },
  end: jest.fn().mockImplementation(function(callback) {
    if (mockDelay) {
      this.delayTimer = setTimeout(callback, 0, mockError, mockResponse);
      return;
    }

    callback(mockError, mockResponse);
  }),
  //expose helper methods for tests to set
  __setMockDelay(boolValue) {
    mockDelay = boolValue;
  },
  __setMockResponse(mockRes) {
    mockResponse = mockRes;
  },
  __setMockError(mockErr) {
    mockError = mockErr;
  },
  __reset() {
    this.__setMockResponse({
      status() {
        return 200;
      },
      ok() {
        return true;
      }
    });
    this.__setMockError(null);
    this.__setMockDelay(false);
  }
};

module.exports = Request;
