Skip to content

Commit

Permalink
Updates dev libs to current versions. (#477)
Browse files Browse the repository at this point in the history
* 449 Updates dev libs to current versions.

* chore(lib/test.js) eslint warn fixed, _assertFunction first argument renamed
  • Loading branch information
mikelax committed May 14, 2018
1 parent d4a63af commit 5209703
Show file tree
Hide file tree
Showing 7 changed files with 1,160 additions and 1,183 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
@@ -1,5 +1,5 @@
{
"extends": "airbnb/legacy",
"extends": "airbnb-base/legacy",
"env": {
"node": true,
"mocha": true
Expand All @@ -11,7 +11,6 @@
"consistent-return": [0],

// Disabled but may want to refactor code eventually
"no-proto": [1],
"no-shadow": [1],
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": [0],
Expand Down
24 changes: 11 additions & 13 deletions index.js
@@ -1,11 +1,9 @@

/**
* Module dependencies.
*/

var methods = require('methods')
, Test = require('./lib/test')
, http = require('http');
var methods = require('methods');
var Test = require('./lib/test');
var http = require('http');

/**
* Test against the given `app`,
Expand All @@ -15,31 +13,31 @@ var methods = require('methods')
* @return {Test}
* @api public
*/

module.exports = function(app){
if ('function' == typeof app) app = http.createServer(app);
module.exports = function(app) {
var obj = {};

methods.forEach(function(method){
obj[method] = function(url){
if (typeof app === 'function') {
app = http.createServer(app); // eslint-disable-line no-param-reassign
}

methods.forEach(function(method) {
obj[method] = function(url) {
return new Test(app, method, url);
};
});

// Support previous use of del
obj.del = obj['delete'];
obj.del = obj.delete;

return obj;
};

/**
* Expose `Test`
*/

module.exports.Test = Test;

/**
* Expose the agent function
*/

module.exports.agent = require('./lib/agent');
4 changes: 2 additions & 2 deletions lib/agent.js
Expand Up @@ -24,7 +24,7 @@ module.exports = TestAgent;

function TestAgent(app, options) {
if (!(this instanceof TestAgent)) return new TestAgent(app, options);
if (typeof app === 'function') app = http.createServer(app); // eslint-disable-line no-param-reassign
if (typeof app === 'function') app = http.createServer(app); // eslint-disable-line no-param-reassign
if (options) {
this._ca = options.ca;
this._key = options.key;
Expand All @@ -48,7 +48,7 @@ TestAgent.prototype.host = function(host) {

// override HTTP verb methods
methods.forEach(function(method) {
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
TestAgent.prototype[method] = function(url, fn) { // eslint-disable-line no-unused-vars
var req = new Test(this.app, method.toUpperCase(), url, this._host);
req.ca(this._ca);
req.cert(this._cert);
Expand Down
10 changes: 5 additions & 5 deletions lib/test.js
Expand Up @@ -123,11 +123,11 @@ Test.prototype.end = function(fn) {
var end = Request.prototype.end;

end.call(this, function(err, res) {
if (server && server._handle) return server.close(assert);
if (server && server._handle) return server.close(localAssert);

assert();
localAssert();

function assert() {
function localAssert() {
self.assert(err, res, fn);
}
});
Expand Down Expand Up @@ -277,10 +277,10 @@ Test.prototype._assertStatus = function(status, res) {
* @return {?Error}
* @api private
*/
Test.prototype._assertFunction = function(check, res) {
Test.prototype._assertFunction = function(fn, res) {
var err;
try {
err = check(res);
err = fn(res);
} catch (e) {
err = e;
}
Expand Down

0 comments on commit 5209703

Please sign in to comment.