fix eslint errors
This commit is contained in:
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@ -0,0 +1,3 @@
|
||||
src/_*
|
||||
src/bower_es_js
|
||||
src/lib/apis
|
||||
@ -107,7 +107,8 @@
|
||||
"scripts": {
|
||||
"test": "grunt test",
|
||||
"generate": "node scripts/generate",
|
||||
"grunt": "grunt"
|
||||
"grunt": "grunt",
|
||||
"eslint": "eslint src scripts test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var _ = require('lodash-migrate');
|
||||
var package = require('../package.json');
|
||||
var branches = package.config.supported_es_branches;
|
||||
var pkg = require('../package.json');
|
||||
var branches = pkg.config.supported_es_branches;
|
||||
var semver = require('semver');
|
||||
|
||||
var maxMinorVersion = function (majorV) {
|
||||
|
||||
@ -60,4 +60,4 @@ function _spawn(cmd, args, opts, cb) {
|
||||
|
||||
_spawn.exec = function (cmd, opts, cb) {
|
||||
return _spawn('/bin/sh', ['-c', cmd], opts, cb);
|
||||
};
|
||||
};
|
||||
|
||||
@ -23,7 +23,7 @@ var through2 = require('through2');
|
||||
var map = require('through2-map');
|
||||
var split = require('split');
|
||||
var join = require('path').join;
|
||||
var child_process = require('child_process');
|
||||
var cp = require('child_process');
|
||||
var chalk = require('chalk');
|
||||
var format = require('util').format;
|
||||
|
||||
@ -59,10 +59,10 @@ task('SAUCE_LABS', false, function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
// build the clients and start the server, once the server is ready call trySaucelabs()
|
||||
var serverTasks = ['browser_clients:build', 'run:browser_test_server:keepalive'];
|
||||
spawn(GRUNT, serverTasks, function (cp) {
|
||||
spawn(GRUNT, serverTasks, function (proc) {
|
||||
var toLines = split();
|
||||
|
||||
cp.stdout
|
||||
proc.stdout
|
||||
.pipe(toLines)
|
||||
.pipe(through2(function (line, enc, cb) {
|
||||
cb();
|
||||
@ -71,11 +71,11 @@ task('SAUCE_LABS', false, function () {
|
||||
|
||||
|
||||
trySaucelabs()
|
||||
.finally(function () { cp && cp.kill(); })
|
||||
.finally(function () { if (proc) proc.kill(); })
|
||||
.then(resolve, reject);
|
||||
|
||||
cp.on('exit', function () { cp = null; });
|
||||
cp.stdout.unpipe(toLines);
|
||||
proc.on('exit', function () { proc = null; });
|
||||
proc.stdout.unpipe(toLines);
|
||||
toLines.end();
|
||||
}));
|
||||
})
|
||||
@ -132,25 +132,30 @@ task('CHECK_COVERAGE', false, function () {
|
||||
execTask('SETUP', function () {
|
||||
return Promise.try(function readVersion() {
|
||||
if (!ENV.ES_V) {
|
||||
if (ENV.ES_RELEASE)
|
||||
if (ENV.ES_RELEASE) {
|
||||
return ['v' + ENV.ES_RELEASE, ENV.ES_RELEASE];
|
||||
}
|
||||
|
||||
if (ENV.ES_REF)
|
||||
if (ENV.ES_REF) {
|
||||
return [ENV.ES_REF, null];
|
||||
}
|
||||
}
|
||||
|
||||
var match;
|
||||
if (match = ENV.ES_V.match(/^(.*)_nightly$/))
|
||||
if (match = ENV.ES_V.match(/^(.*)_nightly$/)) {
|
||||
return [match[1], null];
|
||||
}
|
||||
|
||||
if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V))
|
||||
if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V)) {
|
||||
return ['v' + ENV.ES_V, ENV.ES_V];
|
||||
}
|
||||
|
||||
throw new Error('unable to parse ES_V ' + ENV.ES_V);
|
||||
})
|
||||
.then(function readOtherConf(ver) {
|
||||
if (!ver)
|
||||
if (!ver) {
|
||||
throw new Error('Unable to run the ci script without at least an ES_REF or ES_RELEASE environment var.');
|
||||
}
|
||||
|
||||
log('ES_PORT:', ENV.ES_PORT = parseInt(ENV.ES_PORT || 9400, 10));
|
||||
log('ES_HOST:', ENV.ES_HOST = ENV.ES_HOST || 'localhost');
|
||||
@ -162,8 +167,9 @@ execTask('SETUP', function () {
|
||||
else delete ENV.ES_RELEASE;
|
||||
})
|
||||
.then(function readTasks() {
|
||||
if (!ENV.RUN)
|
||||
if (!ENV.RUN) {
|
||||
return _.where(TASKS, { default: true });
|
||||
}
|
||||
|
||||
return ENV.RUN
|
||||
.split(',')
|
||||
@ -196,7 +202,7 @@ execTask('SETUP', function () {
|
||||
});
|
||||
});
|
||||
|
||||
/******
|
||||
/** ****
|
||||
* utils
|
||||
******/
|
||||
function log() {
|
||||
@ -275,25 +281,25 @@ function execTask(name, task) {
|
||||
|
||||
function spawn(file, args, block) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var cp = child_process.spawn(file, args, {
|
||||
var proc = cp.spawn(file, args, {
|
||||
cwd: ROOT,
|
||||
env: ENV,
|
||||
stdio: [0, 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
cp.stdout.pipe(taskOut, { end: false });
|
||||
cp.stderr.pipe(taskOut, { end: false });
|
||||
proc.stdout.pipe(taskOut, { end: false });
|
||||
proc.stderr.pipe(taskOut, { end: false });
|
||||
|
||||
var stdout = '';
|
||||
cp.stdout
|
||||
proc.stdout
|
||||
.pipe(through2(function (chunk, enc, cb) {
|
||||
stdout += chunk;
|
||||
cb();
|
||||
}));
|
||||
|
||||
block && block(cp);
|
||||
if (block) block(proc);
|
||||
|
||||
cp.on('exit', function (code) {
|
||||
proc.on('exit', function (code) {
|
||||
if (code > 0) {
|
||||
reject(new Error('non-zero exit code: ' + code));
|
||||
} else {
|
||||
@ -301,13 +307,13 @@ function spawn(file, args, block) {
|
||||
}
|
||||
});
|
||||
|
||||
cp.on('error', function (origErr) {
|
||||
proc.on('error', function (origErr) {
|
||||
reject(new Error('Unable to execute "' + file + ' ' + args.join(' ') + '": ' + origErr.message));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function node(/*args... */) {
|
||||
function node(/* args... */) {
|
||||
return spawn(
|
||||
process.execPath,
|
||||
_.toArray(arguments)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*jshint curly: false */
|
||||
/* jshint curly: false */
|
||||
var async = require('async');
|
||||
var fs = require('fs');
|
||||
var spawn = require('../_spawn');
|
||||
@ -206,7 +206,7 @@ function createArchive(branch) {
|
||||
spawnStep('mkdir', [dir], paths.root),
|
||||
spawnStep('git', ['archive', '--format', 'tar', '--output', tarball, branch, specPathInRepo], paths.esSrc),
|
||||
spawnStep('tar', ['-x', '-f', tarball, '-C', dir, '--strip-components', subDirCount]),
|
||||
spawnStep('rm', [tarball])
|
||||
spawnStep('rm', [tarball])
|
||||
], done);
|
||||
};
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ module.exports = function (branch, done) {
|
||||
);
|
||||
}
|
||||
|
||||
function __puke__transformSpec(spec) {
|
||||
function __puke__transformSpec(spec) { // eslint-disable-line
|
||||
var actions = [];
|
||||
|
||||
// itterate all of the specs within the file, should only be one
|
||||
|
||||
@ -187,6 +187,7 @@ module.exports = [
|
||||
version: '>=1.6.0',
|
||||
|
||||
// strange indentation makes pretty api files
|
||||
/* eslint-disable */
|
||||
clientActionModifier:
|
||||
function (spec) {
|
||||
return require('../utils').merge(spec, {
|
||||
@ -198,6 +199,7 @@ function (spec) {
|
||||
}
|
||||
});
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
},
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ var path = require('path');
|
||||
*/
|
||||
function stringify(thing, pretty) {
|
||||
return (pretty ? JSON.stringify(thing, null, ' ') : JSON.stringify(thing))
|
||||
.replace(/\'/g, '\\\'')
|
||||
.replace(/'/g, '\\\'')
|
||||
.replace(/\\?"/g, function (quote) {
|
||||
// replace external (unescaped) double quotes with single quotes
|
||||
return quote === '\\"' ? '"' : '\'';
|
||||
@ -70,16 +70,16 @@ var templateGlobals = {
|
||||
|
||||
paramType: function (type) {
|
||||
switch (type && type.toLowerCase ? type.toLowerCase() : 'any') {
|
||||
case 'time':
|
||||
return 'Date, Number';
|
||||
case 'any':
|
||||
return 'Anything';
|
||||
case 'enum':
|
||||
return 'String';
|
||||
case 'list':
|
||||
return 'String, String[], Boolean';
|
||||
default:
|
||||
return _.ucfirst(type);
|
||||
case 'time':
|
||||
return 'Date, Number';
|
||||
case 'any':
|
||||
return 'Anything';
|
||||
case 'enum':
|
||||
return 'String';
|
||||
case 'list':
|
||||
return 'String, String[], Boolean';
|
||||
default:
|
||||
return _.ucfirst(type);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -55,4 +55,4 @@ module.exports = function (branch, done) {
|
||||
console.log(chalk.white.bold('wrote') + ' YAML index to', file);
|
||||
done();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -42,4 +42,4 @@ async.series([
|
||||
console.log('Error: ', err.message ? err.message : err);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -19,4 +19,4 @@
|
||||
return new es.Client(config);
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
}(jQuery));
|
||||
|
||||
2
test/fixtures/keepalive_server.js
vendored
2
test/fixtures/keepalive_server.js
vendored
@ -13,4 +13,4 @@ var server = require('http').createServer(app);
|
||||
server.listen(function () {
|
||||
var port = server.address().port;
|
||||
process.connected ? process.send(port) : console.log(port);
|
||||
});
|
||||
});
|
||||
|
||||
@ -55,7 +55,8 @@ module.exports = {
|
||||
|
||||
function doCreateClient(options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options, options = {};
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
var logConfig = {};
|
||||
|
||||
@ -37,4 +37,4 @@ module.exports = function (branch) {
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -26,10 +26,10 @@ var ES_VERSION = null;
|
||||
var versionExp = '((?:\\d+\\.){0,2}\\d+)(?:[\\.\\-]\\w+)?|';
|
||||
|
||||
// match all whitespace within a "regexp" match arg
|
||||
var reWhitespace_RE = /\s+/g;
|
||||
var reWhitespaceRE = /\s+/g;
|
||||
|
||||
// match all comments within a "regexp" match arg
|
||||
var reComments_RE = /([\S\s]?)#[^\n]*\n/g;
|
||||
var reCommentsRE = /([\S\s]?)#[^\n]*\n/g;
|
||||
|
||||
/**
|
||||
* Regular Expression to extract a version number from a string
|
||||
@ -356,34 +356,34 @@ YamlDoc.prototype = {
|
||||
|
||||
// resolve the catch arg to a value used for matching once the request is complete
|
||||
switch (args.catch) {
|
||||
case void 0:
|
||||
catcher = null;
|
||||
break;
|
||||
case 'missing':
|
||||
catcher = 404;
|
||||
break;
|
||||
case 'conflict':
|
||||
catcher = 409;
|
||||
break;
|
||||
case 'forbidden':
|
||||
catcher = 403;
|
||||
break;
|
||||
case 'request_timeout':
|
||||
catcher = 408;
|
||||
break;
|
||||
case 'request':
|
||||
catcher = /.*/;
|
||||
break;
|
||||
case 'param':
|
||||
catcher = TypeError;
|
||||
break;
|
||||
default:
|
||||
catcher = args.catch.match(/^\/(.*)\/$/);
|
||||
if (catcher) {
|
||||
catcher = new RegExp(catcher[1]);
|
||||
} else {
|
||||
return done(new TypeError('unsupported catch type ' + args.catch));
|
||||
}
|
||||
case void 0:
|
||||
catcher = null;
|
||||
break;
|
||||
case 'missing':
|
||||
catcher = 404;
|
||||
break;
|
||||
case 'conflict':
|
||||
catcher = 409;
|
||||
break;
|
||||
case 'forbidden':
|
||||
catcher = 403;
|
||||
break;
|
||||
case 'request_timeout':
|
||||
catcher = 408;
|
||||
break;
|
||||
case 'request':
|
||||
catcher = /.*/;
|
||||
break;
|
||||
case 'param':
|
||||
catcher = TypeError;
|
||||
break;
|
||||
default:
|
||||
catcher = args.catch.match(/^\/(.*)\/$/);
|
||||
if (catcher) {
|
||||
catcher = new RegExp(catcher[1]);
|
||||
} else {
|
||||
return done(new TypeError('unsupported catch type ' + args.catch));
|
||||
}
|
||||
}
|
||||
|
||||
delete args.catch;
|
||||
@ -448,7 +448,7 @@ YamlDoc.prototype = {
|
||||
}
|
||||
|
||||
var timeoutId;
|
||||
var cb = _.bind(function (error, body) {
|
||||
var cb = _.bind(function (error, body) {
|
||||
this._last_requests_response = body;
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
@ -588,7 +588,7 @@ YamlDoc.prototype = {
|
||||
// convert the matcher into a compatible string for building a regexp
|
||||
maybeRE = match
|
||||
// replace comments, but allow the # to be escaped like \#
|
||||
.replace(reComments_RE, function (match, prevChar) {
|
||||
.replace(reCommentsRE, function (match, prevChar) {
|
||||
if (prevChar === '\\') {
|
||||
return match;
|
||||
} else {
|
||||
@ -597,7 +597,7 @@ YamlDoc.prototype = {
|
||||
})
|
||||
// remove all whitespace from the expression, all meaningful
|
||||
// whitespace is represented with \s
|
||||
.replace(reWhitespace_RE, '');
|
||||
.replace(reWhitespaceRE, '');
|
||||
|
||||
var startsWithSlash = maybeRE[0] === '/';
|
||||
var endsWithSlash = maybeRE[maybeRE.length - 1] === '/';
|
||||
|
||||
@ -19,7 +19,7 @@ function YamlFile(filename, docs) {
|
||||
|
||||
describe(filename, function () {
|
||||
file.docs = _.map(docs, function (doc) {
|
||||
doc = new YamlDoc(doc, file);
|
||||
doc = new YamlDoc(doc, file);
|
||||
if (doc.description === 'setup') {
|
||||
beforeEach(/* doc */function (done) {
|
||||
async.series(doc.getActionsRunners(), done);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
|
||||
/* eslint-disable */
|
||||
//////////////
|
||||
/// Extended version of:
|
||||
/// https://github.com/philikon/MockHttpRequest/
|
||||
|
||||
@ -57,15 +57,15 @@ var mockNock = module.exports = function (url) {
|
||||
req.status = status;
|
||||
req.body = body;
|
||||
switch (typeof req.body) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
req.body = req.body && JSON.stringify(req.body);
|
||||
} catch (e) {
|
||||
req.body = req.body;
|
||||
}
|
||||
case 'string':
|
||||
case 'number':
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
req.body = req.body && JSON.stringify(req.body);
|
||||
} catch (e) {
|
||||
req.body = req.body;
|
||||
}
|
||||
}
|
||||
interceptors.push(req);
|
||||
return mockNock(url);
|
||||
@ -80,4 +80,4 @@ mockNock.done = function () {
|
||||
if (interceptors.length) {
|
||||
throw new Error('Some interceptors were not called: ' + JSON.stringify(interceptors));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -32,4 +32,4 @@ util.inherits(MockIncommingMessage, Readable);
|
||||
* }
|
||||
* incom.push(null);
|
||||
* });
|
||||
*/
|
||||
*/
|
||||
|
||||
@ -75,4 +75,4 @@ if (Writable) {
|
||||
// There is no shutdown() for files.
|
||||
MockWritableStream.prototype.destroySoon = MockWritableStream.prototype.end;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
2
test/unit/browser_builds/angular.js
vendored
2
test/unit/browser_builds/angular.js
vendored
@ -82,4 +82,4 @@ describe('Angular esFactory', function () {
|
||||
return prom;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -17,4 +17,4 @@ describe('elasticsearch namespace', function () {
|
||||
expect(client.transport).to.be.a(es.Transport);
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
2
test/unit/browser_builds/jquery.js
vendored
2
test/unit/browser_builds/jquery.js
vendored
@ -16,4 +16,4 @@ describe('jQuery.es namespace', function () {
|
||||
expect(client.transport).to.be.a($.es.Transport);
|
||||
client.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -57,4 +57,4 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var blanket = require("blanket")({
|
||||
var blanket = require('blanket')({
|
||||
pattern: require('path').join(__dirname, '../../src')
|
||||
});
|
||||
|
||||
require('./index');
|
||||
require('./index');
|
||||
|
||||
@ -234,4 +234,4 @@ module.exports = function (makeLogger) {
|
||||
expect(logger.write.callCount).to.eql(1);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -3,4 +3,4 @@ require('bluebird').longStackTraces();
|
||||
var specDir = __dirname + '/specs';
|
||||
require('fs').readdirSync(specDir).forEach(function (file) {
|
||||
require(specDir + '/' + file);
|
||||
});
|
||||
});
|
||||
|
||||
@ -32,4 +32,4 @@ describe('Logger Abstract', function () {
|
||||
|
||||
require('../generic_logger_tests')(makeLogger);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -68,7 +68,7 @@ describe('Client instances creation', function () {
|
||||
}
|
||||
util.inherits(NullStream, stream.Writable);
|
||||
|
||||
NullStream.prototype._write = function(/* chunk, encoding, next */) {
|
||||
NullStream.prototype._write = function (/* chunk, encoding, next */) {
|
||||
done();
|
||||
};
|
||||
|
||||
|
||||
@ -195,7 +195,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects array', function (done) {
|
||||
action({
|
||||
one: ['one'],
|
||||
two: [ 1304 ]
|
||||
two: [1304]
|
||||
}, function (err, params) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
@ -629,7 +629,7 @@ describe('Client Action runner', function () {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
action({method: 'get'}, function (err, params) {
|
||||
action({ method: 'get' }, function (err, params) {
|
||||
expect(params.method).to.be('GET');
|
||||
done();
|
||||
});
|
||||
|
||||
@ -17,11 +17,11 @@ describe('Connection Abstract', function () {
|
||||
|
||||
it('requires a valid host', function () {
|
||||
expect(function () {
|
||||
new ConnectionAbstract();
|
||||
var conn = new ConnectionAbstract();
|
||||
}).to.throwError(TypeError);
|
||||
|
||||
expect(function () {
|
||||
new ConnectionAbstract({});
|
||||
var conn = new ConnectionAbstract({});
|
||||
}).to.throwError(TypeError);
|
||||
});
|
||||
|
||||
@ -81,7 +81,6 @@ describe('Connection Abstract', function () {
|
||||
|
||||
it('calls it\'s own request method', function () {
|
||||
var conn = new ConnectionAbstract(host);
|
||||
var football = {};
|
||||
stub(conn, 'request');
|
||||
conn.ping();
|
||||
expect(conn.request.callCount).to.eql(1);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
var ConnectionPool = require('../../../src/lib/connection_pool');
|
||||
var Host = require('../../../src/lib/host');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
var ConnectionAbstract = require('../../../src/lib/connection');
|
||||
var _ = require('lodash-migrate');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
@ -121,7 +120,7 @@ describe('Connection Pool', function () {
|
||||
});
|
||||
|
||||
it('detects if the selector is not async', function (done) {
|
||||
pool.selector = function (list) {
|
||||
pool.selector = function () {
|
||||
expect(arguments.length).to.be(1);
|
||||
};
|
||||
|
||||
@ -149,11 +148,11 @@ describe('Connection Pool', function () {
|
||||
});
|
||||
|
||||
it('should catch errors in sync selectors', function (done) {
|
||||
pool.selector = function (list) {
|
||||
pool.selector = function () {
|
||||
return JSON.notAMethod();
|
||||
};
|
||||
|
||||
pool.select(function (err, selection) {
|
||||
pool.select(function (err) {
|
||||
expect(err).be.an(Error);
|
||||
done();
|
||||
});
|
||||
@ -297,7 +296,8 @@ describe('Connection Pool', function () {
|
||||
var result = pool.getConnections();
|
||||
expect(result.length).to.be(1000);
|
||||
expect(_.reduce(result, function (sum, num) {
|
||||
return sum += num;
|
||||
sum += num
|
||||
return sum;
|
||||
}, 0)).to.eql(499500);
|
||||
});
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@ describe('Host class', function () {
|
||||
});
|
||||
|
||||
it('accepts a string for query', function () {
|
||||
var host = new Host({ query: 'beep=boop'});
|
||||
var host = new Host({ query: 'beep=boop' });
|
||||
|
||||
expect(host.query).to.eql({
|
||||
beep: 'boop'
|
||||
@ -157,14 +157,14 @@ describe('Host class', function () {
|
||||
var host = new Host();
|
||||
host.path = 'prefix';
|
||||
|
||||
expect(host.makeUrl({ path: '/this and that'}))
|
||||
expect(host.makeUrl({ path: '/this and that' }))
|
||||
.to.be('http://localhost:9200/prefix/this and that');
|
||||
});
|
||||
|
||||
it('does not try to prevent double forward-slashes', function () {
|
||||
var host = new Host({ path: 'prefix/' });
|
||||
|
||||
expect(host.makeUrl({ path: '/this and that'}))
|
||||
expect(host.makeUrl({ path: '/this and that' }))
|
||||
.to.be('http://localhost:9200/prefix//this and that');
|
||||
});
|
||||
|
||||
@ -175,7 +175,7 @@ describe('Host class', function () {
|
||||
host = new Host({ host: 'john', port: 80 });
|
||||
expect(host.makeUrl()).to.be('http://john/');
|
||||
|
||||
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass'});
|
||||
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass' });
|
||||
expect(host.makeUrl()).to.be('http://italy:9200/pie');
|
||||
});
|
||||
|
||||
|
||||
@ -324,7 +324,7 @@ describe('Http Connector', function () {
|
||||
zlib.gzip(body, function (err, compressedBody) {
|
||||
server
|
||||
.get('/users/1')
|
||||
.reply(200, compressedBody, {'Content-Encoding': 'gzip'});
|
||||
.reply(200, compressedBody, { 'Content-Encoding': 'gzip' });
|
||||
|
||||
con.request({
|
||||
method: 'GET',
|
||||
@ -350,7 +350,7 @@ describe('Http Connector', function () {
|
||||
zlib.deflate(body, function (err, compressedBody) {
|
||||
server
|
||||
.get('/users/1')
|
||||
.reply(200, compressedBody, {'Content-Encoding': 'deflate'});
|
||||
.reply(200, compressedBody, { 'Content-Encoding': 'deflate' });
|
||||
|
||||
con.request({
|
||||
method: 'GET',
|
||||
@ -371,7 +371,7 @@ describe('Http Connector', function () {
|
||||
var body = 'blah';
|
||||
server
|
||||
.get('/users/1')
|
||||
.reply(200, body, {'Content-Encoding': 'gzip'});
|
||||
.reply(200, body, { 'Content-Encoding': 'gzip' });
|
||||
|
||||
con.request({
|
||||
method: 'GET',
|
||||
|
||||
@ -97,4 +97,4 @@ describe('JSON serializer', function () {
|
||||
}).to.throwError();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -141,7 +141,7 @@ describe('Log class', function () {
|
||||
|
||||
log.emit = function (eventName) {
|
||||
call = {
|
||||
event : eventName,
|
||||
event: eventName,
|
||||
args: Array.prototype.slice.call(arguments, 1)
|
||||
};
|
||||
};
|
||||
@ -221,7 +221,7 @@ describe('Log class', function () {
|
||||
});
|
||||
|
||||
it('accepts an array of output config objects', function () {
|
||||
var log = new Log({ log: [{ level: 'error' }, { level: 'trace'}] });
|
||||
var log = new Log({ log: [{ level: 'error' }, { level: 'trace' }] });
|
||||
expect(log.listenerCount('error')).to.eql(2);
|
||||
expect(log.listenerCount('warning')).to.eql(1);
|
||||
expect(log.listenerCount('info')).to.eql(1);
|
||||
|
||||
@ -61,7 +61,6 @@ describe('Nodes to host callback', function () {
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('ignores hosts that don\'t have an http_host property', function () {
|
||||
var hosts = callback({
|
||||
node_id: {
|
||||
@ -74,7 +73,7 @@ describe('Nodes to host callback', function () {
|
||||
|
||||
it('throws an error when the host property is not formatted properly', function () {
|
||||
expect(function () {
|
||||
var hosts = callback({
|
||||
callback({
|
||||
node_id: {
|
||||
http_address: 'not actually an http host'
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
var Transport = require('../../../src/lib/transport');
|
||||
var Host = require('../../../src/lib/host');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
var sinon = require('sinon');
|
||||
var expect = require('expect.js');
|
||||
@ -354,10 +353,10 @@ describe('Transport Class', function () {
|
||||
});
|
||||
|
||||
it('logs an error if nodes to host throws one', function (done) {
|
||||
trans.nodesToHostCallback = function (nodes) {
|
||||
trans.nodesToHostCallback = function () {
|
||||
throw new Error('I failed');
|
||||
};
|
||||
trans.log.error = function (err) {
|
||||
trans.log.error = function () {
|
||||
done();
|
||||
};
|
||||
trans.sniff();
|
||||
@ -408,7 +407,7 @@ describe('Transport Class', function () {
|
||||
});
|
||||
});
|
||||
it('passed back the full server response', function (done) {
|
||||
trans.sniff(function (err, resp, status) {
|
||||
trans.sniff(function (err, resp) {
|
||||
expect(resp.ok).to.eql(true);
|
||||
expect(resp.cluster_name).to.eql('clustername');
|
||||
done();
|
||||
@ -501,7 +500,7 @@ describe('Transport Class', function () {
|
||||
});
|
||||
var conn = getConnection(trans);
|
||||
var body = [
|
||||
{ _id: 'simple body'},
|
||||
{ _id: 'simple body' },
|
||||
{ name: 'ഢധയമബ' }
|
||||
];
|
||||
|
||||
@ -526,7 +525,7 @@ describe('Transport Class', function () {
|
||||
var trans = new Transport({
|
||||
hosts: 'localhost'
|
||||
});
|
||||
var conn = getConnection(trans);
|
||||
getConnection(trans);
|
||||
var body = {
|
||||
_id: 'circular body'
|
||||
};
|
||||
@ -560,7 +559,7 @@ describe('Transport Class', function () {
|
||||
}
|
||||
});
|
||||
|
||||
trans.request({}, function (err, body, status) {
|
||||
trans.request({}, function (err) {
|
||||
expect(err.message).to.eql('I am broken');
|
||||
});
|
||||
});
|
||||
@ -574,7 +573,7 @@ describe('Transport Class', function () {
|
||||
}
|
||||
});
|
||||
|
||||
trans.request({}, function (err, body, status) {
|
||||
trans.request({}, function (err) {
|
||||
expect(err.message).to.eql('I am broken');
|
||||
});
|
||||
});
|
||||
@ -638,7 +637,6 @@ describe('Transport Class', function () {
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe('return value', function () {
|
||||
it('returns an object with an abort() method when a callback is sent', function () {
|
||||
var tran = new Transport();
|
||||
@ -681,7 +679,7 @@ describe('Transport Class', function () {
|
||||
expect(process.domain).to.be(null);
|
||||
var tran = new Transport();
|
||||
shortCircuitRequest(tran);
|
||||
tran.request({}, function(err, result, status) {
|
||||
tran.request({}, function () {
|
||||
expect(process.domain).to.be(null);
|
||||
});
|
||||
});
|
||||
@ -689,12 +687,12 @@ describe('Transport Class', function () {
|
||||
it('binds the callback to the correct domain', function () {
|
||||
expect(process.domain).to.be(null);
|
||||
var domain = require('domain').create();
|
||||
domain.run(function() {
|
||||
domain.run(function () {
|
||||
var tran = new Transport();
|
||||
shortCircuitRequest(tran);
|
||||
expect(process.domain).not.to.be(null);
|
||||
var startingDomain = process.domain
|
||||
tran.request({}, function(err, result, status) {
|
||||
tran.request({}, function () {
|
||||
expect(process.domain).not.to.be(null);
|
||||
expect(process.domain).to.be(startingDomain);
|
||||
process.domain.exit();
|
||||
@ -758,7 +756,6 @@ describe('Transport Class', function () {
|
||||
var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout');
|
||||
stub.autoRelease(clock);
|
||||
var tran = new Transport({});
|
||||
var err;
|
||||
|
||||
var prom = tran.request({});
|
||||
// disregard promise, prevent bluebird's warnings
|
||||
@ -776,7 +773,6 @@ describe('Transport Class', function () {
|
||||
var tran = new Transport({
|
||||
requestTimeout: 5000
|
||||
});
|
||||
var err;
|
||||
|
||||
var prom = tran.request({});
|
||||
// disregard promise, prevent bluebird's warnings
|
||||
@ -799,7 +795,7 @@ describe('Transport Class', function () {
|
||||
|
||||
tran.request({
|
||||
requestTimeout: falsy
|
||||
}, function (_err) {});
|
||||
}, function () {});
|
||||
|
||||
expect(_.size(clock.timers)).to.eql(0);
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@ describe('Utils', function () {
|
||||
}
|
||||
},
|
||||
function (thing, name) {
|
||||
describe('#isArrayOf' + name, function (test) {
|
||||
describe('#isArrayOf' + name, function () {
|
||||
it('likes arrays of ' + name, function () {
|
||||
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(true);
|
||||
});
|
||||
@ -54,7 +54,6 @@ describe('Utils', function () {
|
||||
expect(_.isNumeric(0)).to.be(true);
|
||||
expect(_.isNumeric(32)).to.be(true);
|
||||
expect(_.isNumeric('040')).to.be(true);
|
||||
expect(_.isNumeric(0144)).to.be(true);
|
||||
expect(_.isNumeric('0xFF')).to.be(true);
|
||||
expect(_.isNumeric(0xFFF)).to.be(true);
|
||||
});
|
||||
@ -196,7 +195,7 @@ describe('Utils', function () {
|
||||
});
|
||||
|
||||
it('sorta kinda works on objects', function () {
|
||||
expect(_.toLowerString({a: 'thing'})).to.eql('[object object]');
|
||||
expect(_.toLowerString({ a: 'thing' })).to.eql('[object object]');
|
||||
});
|
||||
});
|
||||
|
||||
@ -216,7 +215,7 @@ describe('Utils', function () {
|
||||
});
|
||||
|
||||
it('sorta kinda works on objects', function () {
|
||||
expect(_.toUpperString({a: 'thing'})).to.eql('[OBJECT OBJECT]');
|
||||
expect(_.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
|
||||
});
|
||||
});
|
||||
|
||||
@ -268,7 +267,7 @@ describe('Utils', function () {
|
||||
foo: ['bax', 'boz']
|
||||
}
|
||||
};
|
||||
_.deepMerge(obj, { bax: { foo: ['poo'] }});
|
||||
_.deepMerge(obj, { bax: { foo: ['poo'] } });
|
||||
expect(obj.bax.foo).to.have.length(3);
|
||||
});
|
||||
|
||||
@ -282,7 +281,7 @@ describe('Utils', function () {
|
||||
expect(out).to.not.be(inp);
|
||||
});
|
||||
it('accepts a primitive value and calls the the transform function', function (done) {
|
||||
var out = _.createArray('str', function (val) {
|
||||
_.createArray('str', function (val) {
|
||||
expect(val).to.be('str');
|
||||
done();
|
||||
});
|
||||
|
||||
@ -19,4 +19,4 @@ describe('Yaml Test Reader', function () {
|
||||
expect(compare('0.90 - 1.2', '1.4')).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -18,4 +18,4 @@ exports.make = function () {
|
||||
};
|
||||
|
||||
return stubber;
|
||||
};
|
||||
};
|
||||
|
||||
@ -9,4 +9,4 @@ module.exports = function expectSubObject(obj, subObj) {
|
||||
expect(obj).property(prop, val);
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -22,7 +22,7 @@ var log = (function () {
|
||||
}
|
||||
locked(str);
|
||||
};
|
||||
})();
|
||||
}());
|
||||
|
||||
var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; });
|
||||
var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; });
|
||||
@ -86,7 +86,7 @@ function JenkinsReporter(runner) {
|
||||
stack.shift();
|
||||
});
|
||||
|
||||
runner.on('fail', function (test, err) {
|
||||
runner.on('fail', function (test) {
|
||||
if ('hook' === test.type) {
|
||||
runner.emit('test end', test);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ function makeJUnitXml(runnerName, testDetails) {
|
||||
timestamp: moment(suiteInfo.start).toJSON(),
|
||||
hostname: 'localhost',
|
||||
tests: (suiteInfo.results && suiteInfo.results.length) || 0,
|
||||
failures: _.where(suiteInfo.results, {pass: false}).length,
|
||||
failures: _.where(suiteInfo.results, { pass: false }).length,
|
||||
errors: 0,
|
||||
time: suiteInfo.time / 1000
|
||||
});
|
||||
@ -89,7 +89,7 @@ function makeJUnitXml(runnerName, testDetails) {
|
||||
giveOutput(suite, suiteInfo);
|
||||
});
|
||||
|
||||
return suites.toString({ pretty: true});
|
||||
return suites.toString({ pretty: true });
|
||||
}
|
||||
|
||||
function giveOutput(el, info) {
|
||||
@ -103,4 +103,4 @@ function giveOutput(el, info) {
|
||||
if (err) {
|
||||
el.ele('system-err', {}).cdata(chalk.stripColor(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/no-unresolved */
|
||||
var express = require('express');
|
||||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
@ -31,6 +32,8 @@ testFiles.build = fs.readdirSync(browserBuildsDir)
|
||||
if (file.substr(-3) === '.js') {
|
||||
return browserBuildsDir + '/' + file;
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
@ -73,7 +76,7 @@ function bundleTests(name) {
|
||||
|
||||
// create a route that just rends a specific file (like a symlink or something)
|
||||
function sendFile(file) {
|
||||
return function (req, res, next) {
|
||||
return function (req, res) {
|
||||
res.sendfile(file);
|
||||
};
|
||||
}
|
||||
@ -111,4 +114,4 @@ app
|
||||
|
||||
http.createServer(app).listen(8000, function () {
|
||||
console.log('listening on port 8000');
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,4 +3,4 @@
|
||||
module.exports = JSON.parse(new Buffer(
|
||||
'eyJ1c2VyIjoiZWxhc3RpY3NlYXJjaC1qcyIsImtleSI6IjI0ZjQ5ZTA3LWQ4MmYtNDA2Ny04NTRlLWQ4MTVlYmQxNWU0NiJ9',
|
||||
'base64'
|
||||
).toString('utf8'));
|
||||
).toString('utf8'));
|
||||
|
||||
Reference in New Issue
Block a user