[eslint] remove exception for no-unused-vars, fix violations
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
extends: "@elastic/eslint-config-kibana"
|
extends: "@elastic/eslint-config-kibana"
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
no-unused-vars: warn
|
|
||||||
semi: warn
|
semi: warn
|
||||||
one-var: warn
|
one-var: warn
|
||||||
new-cap: warn
|
new-cap: warn
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
module.exports = function (branch) {
|
module.exports = function (branch) {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const jsYaml = require('js-yaml');
|
|
||||||
const YamlFile = require('./yaml_file');
|
const YamlFile = require('./yaml_file');
|
||||||
const root = require('find-root')(__dirname);
|
const root = require('find-root')(__dirname);
|
||||||
const rootReq = function (loc) { return require(path.join(root, loc)); };
|
const rootReq = function (loc) { return require(path.join(root, loc)); };
|
||||||
const _ = rootReq('src/lib/utils');
|
const _ = rootReq('src/lib/utils');
|
||||||
const utils = rootReq('grunt/utils');
|
|
||||||
const es = rootReq('src/elasticsearch');
|
|
||||||
const clientManager = require('./client_manager');
|
const clientManager = require('./client_manager');
|
||||||
|
|
||||||
const port = parseInt(process.env.ES_PORT || 9200, 10);
|
const port = parseInt(process.env.ES_PORT || 9200, 10);
|
||||||
@ -32,8 +29,8 @@ module.exports = function (branch) {
|
|||||||
return clientManager.get().clearEs();
|
return clientManager.get().clearEs();
|
||||||
});
|
});
|
||||||
|
|
||||||
const files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) {
|
_.each(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) {
|
||||||
return new YamlFile(filename, docs);
|
new YamlFile(filename, docs);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,20 +12,19 @@ if (Writable) {
|
|||||||
// nice and simple for streams 2
|
// nice and simple for streams 2
|
||||||
MockWritableStream = module.exports = function (opts) {
|
MockWritableStream = module.exports = function (opts) {
|
||||||
Writable.call(this, opts);
|
Writable.call(this, opts);
|
||||||
|
this._write = function () {};
|
||||||
this._write = function (chunk, encoding, cb) {};
|
|
||||||
};
|
};
|
||||||
util.inherits(MockWritableStream, Writable);
|
util.inherits(MockWritableStream, Writable);
|
||||||
} else {
|
} else {
|
||||||
// Node < 0.10 did not provide a usefull stream abstract
|
// Node < 0.10 did not provide a usefull stream abstract
|
||||||
const Stream = require('stream').Stream;
|
const Stream = require('stream').Stream;
|
||||||
module.exports = MockWritableStream = function (opts) {
|
module.exports = MockWritableStream = function () {
|
||||||
Stream.call(this);
|
Stream.call(this);
|
||||||
this.writable = true;
|
this.writable = true;
|
||||||
};
|
};
|
||||||
util.inherits(MockWritableStream, Stream);
|
util.inherits(MockWritableStream, Stream);
|
||||||
|
|
||||||
MockWritableStream.prototype.write = function (data) {
|
MockWritableStream.prototype.write = function () {
|
||||||
if (!this.writable) {
|
if (!this.writable) {
|
||||||
this.emit('error', new Error('stream not writable'));
|
this.emit('error', new Error('stream not writable'));
|
||||||
return false;
|
return false;
|
||||||
@ -41,15 +40,15 @@ if (Writable) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MockWritableStream.prototype.end = function (data, encoding, cb) {
|
MockWritableStream.prototype.end = function (data, encoding) {
|
||||||
if (typeof (data) === 'function') {
|
if (typeof (data) === 'function') {
|
||||||
cb = data;
|
// data is a cb
|
||||||
} else if (typeof (encoding) === 'function') {
|
} else if (typeof (encoding) === 'function') {
|
||||||
cb = encoding;
|
|
||||||
this.write(data);
|
this.write(data);
|
||||||
} else if (arguments.length > 0) {
|
} else if (arguments.length > 0) {
|
||||||
this.write(data, encoding);
|
this.write(data, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.writable = false;
|
this.writable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
7
test/unit/browser_builds/angular.js
vendored
7
test/unit/browser_builds/angular.js
vendored
@ -2,18 +2,14 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const sinon = require('sinon');
|
|
||||||
|
|
||||||
describe('Angular esFactory', function () {
|
describe('Angular esFactory', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
require('../../../src/elasticsearch.angular.js');
|
require('../../../src/elasticsearch.angular.js');
|
||||||
});
|
});
|
||||||
|
|
||||||
const uuid = (function () { let i = 0; return function () { return ++i; }; }());
|
|
||||||
let esFactory;
|
let esFactory;
|
||||||
let $http;
|
|
||||||
let $rootScope;
|
let $rootScope;
|
||||||
let $httpBackend;
|
|
||||||
|
|
||||||
function bootstrap(env) {
|
function bootstrap(env) {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -37,10 +33,8 @@ describe('Angular esFactory', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(function ($injector) {
|
beforeEach(angular.mock.inject(function ($injector) {
|
||||||
$http = $injector.get('$http');
|
|
||||||
esFactory = $injector.get('esFactory');
|
esFactory = $injector.get('esFactory');
|
||||||
$rootScope = $injector.get('$rootScope');
|
$rootScope = $injector.get('$rootScope');
|
||||||
$httpBackend = $injector.get('$httpBackend');
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +64,6 @@ describe('Angular esFactory', function () {
|
|||||||
|
|
||||||
it('returns an error created by calling a method incorrectly', function () {
|
it('returns an error created by calling a method incorrectly', function () {
|
||||||
const client = esFactory({ hosts: null });
|
const client = esFactory({ hosts: null });
|
||||||
let err;
|
|
||||||
|
|
||||||
const prom = client.get().then(function () {
|
const prom = client.get().then(function () {
|
||||||
throw new Error('expected request to fail');
|
throw new Error('expected request to fail');
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const Transport = require('../../../src/lib/transport');
|
|
||||||
|
|
||||||
describe('elasticsearch namespace', function () {
|
describe('elasticsearch namespace', function () {
|
||||||
const es = window.elasticsearch;
|
const es = window.elasticsearch;
|
||||||
|
|||||||
1
test/unit/browser_builds/jquery.js
vendored
1
test/unit/browser_builds/jquery.js
vendored
@ -1,6 +1,5 @@
|
|||||||
/* global $ */
|
/* global $ */
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const Transport = require('../../../src/lib/transport');
|
|
||||||
|
|
||||||
describe('jQuery.es namespace', function () {
|
describe('jQuery.es namespace', function () {
|
||||||
it('is defined on the global jQuery', function () {
|
it('is defined on the global jQuery', function () {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ module.exports = function (makeLogger) {
|
|||||||
once.call(process, event, handler);
|
once.call(process, event, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
const logger = makeLogger();
|
makeLogger();
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
// call the event handler
|
// call the event handler
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const blanket = require('blanket')({
|
require('blanket')({
|
||||||
pattern: require('path').join(__dirname, '../../src')
|
pattern: require('path').join(__dirname, '../../src')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const Log = require('../../src/lib/log');
|
const Log = require('../../src/lib/log');
|
||||||
const LoggerAbstract = require('../../src/lib/logger');
|
|
||||||
const TracerLogger = require('../../src/lib/loggers/tracer');
|
|
||||||
const now = new Date('2013-03-01T00:00:00Z');
|
const now = new Date('2013-03-01T00:00:00Z');
|
||||||
const sinon = require('sinon');
|
const sinon = require('sinon');
|
||||||
|
|
||||||
@ -24,7 +22,7 @@ module.exports = function (makeLogger) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('listens for the loggers\' "closing" event', function () {
|
it('listens for the loggers\' "closing" event', function () {
|
||||||
const logger = makeLogger(parent);
|
makeLogger(parent);
|
||||||
expect(parent.listenerCount('closing')).to.eql(1);
|
expect(parent.listenerCount('closing')).to.eql(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -38,7 +36,7 @@ module.exports = function (makeLogger) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('listens to just error when log is explicitly error', function () {
|
it('listens to just error when log is explicitly error', function () {
|
||||||
const logger = makeLogger(parent, 'error');
|
makeLogger(parent, 'error');
|
||||||
expect(parent.listenerCount('error')).to.eql(1);
|
expect(parent.listenerCount('error')).to.eql(1);
|
||||||
expect(parent.listenerCount('warning')).to.eql(0);
|
expect(parent.listenerCount('warning')).to.eql(0);
|
||||||
expect(parent.listenerCount('info')).to.eql(0);
|
expect(parent.listenerCount('info')).to.eql(0);
|
||||||
@ -47,7 +45,7 @@ module.exports = function (makeLogger) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('listens for all the events when level is "trace"', function () {
|
it('listens for all the events when level is "trace"', function () {
|
||||||
const logger = makeLogger(parent, 'trace');
|
makeLogger(parent, 'trace');
|
||||||
expect(parent.listenerCount('error')).to.eql(1);
|
expect(parent.listenerCount('error')).to.eql(1);
|
||||||
expect(parent.listenerCount('warning')).to.eql(1);
|
expect(parent.listenerCount('warning')).to.eql(1);
|
||||||
expect(parent.listenerCount('info')).to.eql(1);
|
expect(parent.listenerCount('info')).to.eql(1);
|
||||||
@ -56,7 +54,7 @@ module.exports = function (makeLogger) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('listens for specific events when level is an array', function () {
|
it('listens for specific events when level is an array', function () {
|
||||||
const logger = makeLogger(parent, ['error', 'trace']);
|
makeLogger(parent, ['error', 'trace']);
|
||||||
expect(parent.listenerCount('error')).to.eql(1);
|
expect(parent.listenerCount('error')).to.eql(1);
|
||||||
expect(parent.listenerCount('warning')).to.eql(0);
|
expect(parent.listenerCount('warning')).to.eql(0);
|
||||||
expect(parent.listenerCount('info')).to.eql(0);
|
expect(parent.listenerCount('info')).to.eql(0);
|
||||||
@ -87,7 +85,7 @@ module.exports = function (makeLogger) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emits events because something is listening', function () {
|
it('emits events because something is listening', function () {
|
||||||
const logger = makeLogger(parent, 'trace');
|
makeLogger(parent, 'trace');
|
||||||
stub(parent, 'emit');
|
stub(parent, 'emit');
|
||||||
|
|
||||||
parent.error(new Error('error message'));
|
parent.error(new Error('error message'));
|
||||||
@ -142,7 +140,7 @@ module.exports = function (makeLogger) {
|
|||||||
describe('#onError', function () {
|
describe('#onError', function () {
|
||||||
it('uses the Error name when it is not just "Error"', function () {
|
it('uses the Error name when it is not just "Error"', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('TypeError');
|
expect(label).to.eql('TypeError');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,7 +150,7 @@ module.exports = function (makeLogger) {
|
|||||||
|
|
||||||
it('uses "ERROR" when the error name is "Error"', function () {
|
it('uses "ERROR" when the error name is "Error"', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('ERROR');
|
expect(label).to.eql('ERROR');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -164,7 +162,7 @@ module.exports = function (makeLogger) {
|
|||||||
describe('#onWarning', function () {
|
describe('#onWarning', function () {
|
||||||
it('uses the "WARNING" label', function () {
|
it('uses the "WARNING" label', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('WARNING');
|
expect(label).to.eql('WARNING');
|
||||||
});
|
});
|
||||||
logger.onWarning('message');
|
logger.onWarning('message');
|
||||||
@ -185,7 +183,7 @@ module.exports = function (makeLogger) {
|
|||||||
describe('#onInfo', function () {
|
describe('#onInfo', function () {
|
||||||
it('uses the "INFO" label', function () {
|
it('uses the "INFO" label', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('INFO');
|
expect(label).to.eql('INFO');
|
||||||
});
|
});
|
||||||
logger.onInfo('message');
|
logger.onInfo('message');
|
||||||
@ -206,7 +204,7 @@ module.exports = function (makeLogger) {
|
|||||||
describe('#onDebug', function () {
|
describe('#onDebug', function () {
|
||||||
it('uses the "DEBUG" label', function () {
|
it('uses the "DEBUG" label', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('DEBUG');
|
expect(label).to.eql('DEBUG');
|
||||||
});
|
});
|
||||||
logger.onDebug('message');
|
logger.onDebug('message');
|
||||||
@ -227,7 +225,7 @@ module.exports = function (makeLogger) {
|
|||||||
describe('#onTrace', function () {
|
describe('#onTrace', function () {
|
||||||
it('uses the "TRACE" label', function () {
|
it('uses the "TRACE" label', function () {
|
||||||
const logger = makeLogger();
|
const logger = makeLogger();
|
||||||
stub(logger, 'write', function (label, msg) {
|
stub(logger, 'write', function (label) {
|
||||||
expect(label).to.eql('TRACE');
|
expect(label).to.eql('TRACE');
|
||||||
});
|
});
|
||||||
logger.onTrace(Log.normalizeTraceArgs('GET', 'http://place/thing?me=true', '{}', '{"ok": true}', 200));
|
logger.onTrace(Log.normalizeTraceArgs('GET', 'http://place/thing?me=true', '{}', '{"ok": true}', 200));
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
describe('Logger Abstract', function () {
|
describe('Logger Abstract', function () {
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const sinon = require('sinon');
|
|
||||||
const Log = require('../../../src/lib/log');
|
const Log = require('../../../src/lib/log');
|
||||||
const LoggerAbstract = require('../../../src/lib/logger');
|
const LoggerAbstract = require('../../../src/lib/logger');
|
||||||
|
|
||||||
let parentLog;
|
let parentLog;
|
||||||
const stub = require('../../utils/auto_release_stub').make();
|
|
||||||
|
|
||||||
function makeLogger(parent, levels) {
|
function makeLogger(parent, levels) {
|
||||||
return new LoggerAbstract(parent || parentLog, {
|
return new LoggerAbstract(parent || parentLog, {
|
||||||
|
|||||||
@ -92,7 +92,7 @@ describe('Client Action runner', function () {
|
|||||||
|
|
||||||
describe('clientAction::proxy', function () {
|
describe('clientAction::proxy', function () {
|
||||||
it('proxies to the passed function', function () {
|
it('proxies to the passed function', function () {
|
||||||
const action = makeClientActionProxy(function (params, cb) {
|
const action = makeClientActionProxy(function () {
|
||||||
throw new Error('proxy function called');
|
throw new Error('proxy function called');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ describe('Client Action runner', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
action({}, function (err, params) {
|
action({}, function () {
|
||||||
expect(client.transport.request).to.be.a('function');
|
expect(client.transport.request).to.be.a('function');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -126,7 +126,7 @@ describe('Client Action runner', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('supports a param transformation function', function () {
|
it('supports a param transformation function', function () {
|
||||||
const action = makeClientActionProxy(function (params, cb) {
|
const action = makeClientActionProxy(function (params) {
|
||||||
expect(params).to.have.property('transformed');
|
expect(params).to.have.property('transformed');
|
||||||
}, {
|
}, {
|
||||||
transform: function (params) {
|
transform: function (params) {
|
||||||
@ -139,7 +139,7 @@ describe('Client Action runner', function () {
|
|||||||
|
|
||||||
it('returns the proxied function\'s return value', function () {
|
it('returns the proxied function\'s return value', function () {
|
||||||
const football = {};
|
const football = {};
|
||||||
const action = makeClientActionProxy(function (params, cb) {
|
const action = makeClientActionProxy(function () {
|
||||||
return football;
|
return football;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects date values', function (done) {
|
it('rejects date values', function (done) {
|
||||||
action({
|
action({
|
||||||
one: new Date()
|
one: new Date()
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -196,7 +196,7 @@ describe('Client Action runner', function () {
|
|||||||
action({
|
action({
|
||||||
one: ['one'],
|
one: ['one'],
|
||||||
two: [1304]
|
two: [1304]
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -205,7 +205,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects object', function (done) {
|
it('rejects object', function (done) {
|
||||||
action({
|
action({
|
||||||
one: { but: 'duration' }
|
one: { but: 'duration' }
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -242,7 +242,7 @@ describe('Client Action runner', function () {
|
|||||||
it('it rejects regexp', function (done) {
|
it('it rejects regexp', function (done) {
|
||||||
action({
|
action({
|
||||||
one: /regexp!/g
|
one: /regexp!/g
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -253,7 +253,7 @@ describe('Client Action runner', function () {
|
|||||||
one: {
|
one: {
|
||||||
pasta: 'sauce'
|
pasta: 'sauce'
|
||||||
}
|
}
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -302,7 +302,7 @@ describe('Client Action runner', function () {
|
|||||||
it('it rejects things not in the list', function (done) {
|
it('it rejects things not in the list', function (done) {
|
||||||
action({
|
action({
|
||||||
one: 'not an opt'
|
one: 'not an opt'
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -417,7 +417,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects dates', function (done) {
|
it('rejects dates', function (done) {
|
||||||
action({
|
action({
|
||||||
one: new Date()
|
one: new Date()
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -426,7 +426,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects objects', function (done) {
|
it('rejects objects', function (done) {
|
||||||
action({
|
action({
|
||||||
one: {}
|
one: {}
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -435,7 +435,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects arrays', function (done) {
|
it('rejects arrays', function (done) {
|
||||||
action({
|
action({
|
||||||
one: []
|
one: []
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -444,7 +444,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects regexp', function (done) {
|
it('rejects regexp', function (done) {
|
||||||
action({
|
action({
|
||||||
one: /pasta/g
|
one: /pasta/g
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -488,7 +488,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects dates', function (done) {
|
it('rejects dates', function (done) {
|
||||||
action({
|
action({
|
||||||
one: new Date()
|
one: new Date()
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -497,7 +497,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects objects', function (done) {
|
it('rejects objects', function (done) {
|
||||||
action({
|
action({
|
||||||
one: {}
|
one: {}
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -506,7 +506,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects arrays', function (done) {
|
it('rejects arrays', function (done) {
|
||||||
action({
|
action({
|
||||||
one: []
|
one: []
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -515,7 +515,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects regexp', function (done) {
|
it('rejects regexp', function (done) {
|
||||||
action({
|
action({
|
||||||
one: /pasta/g
|
one: /pasta/g
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -559,7 +559,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects objects', function (done) {
|
it('rejects objects', function (done) {
|
||||||
action({
|
action({
|
||||||
one: {}
|
one: {}
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -568,7 +568,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects arrays', function (done) {
|
it('rejects arrays', function (done) {
|
||||||
action({
|
action({
|
||||||
one: []
|
one: []
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -577,7 +577,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects regexp', function (done) {
|
it('rejects regexp', function (done) {
|
||||||
action({
|
action({
|
||||||
one: /pasta/g
|
one: /pasta/g
|
||||||
}, function (err, params) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -732,7 +732,7 @@ describe('Client Action runner', function () {
|
|||||||
it('rejects a url if it required params that are not present', function (done) {
|
it('rejects a url if it required params that are not present', function (done) {
|
||||||
action(params({
|
action(params({
|
||||||
type: ['type1', 'type2']
|
type: ['type1', 'type2']
|
||||||
}), function (err, resp) {
|
}), function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
params.check();
|
params.check();
|
||||||
done();
|
done();
|
||||||
@ -845,7 +845,7 @@ describe('Client Action runner', function () {
|
|||||||
it('enforces required params', function (done) {
|
it('enforces required params', function (done) {
|
||||||
action(params({
|
action(params({
|
||||||
b: '3w'
|
b: '3w'
|
||||||
}), function (err, resp) {
|
}), function (err) {
|
||||||
expect(err).to.be.a(TypeError);
|
expect(err).to.be.a(TypeError);
|
||||||
params.check();
|
params.check();
|
||||||
done();
|
done();
|
||||||
|
|||||||
@ -17,11 +17,11 @@ describe('Connection Abstract', function () {
|
|||||||
|
|
||||||
it('requires a valid host', function () {
|
it('requires a valid host', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const conn = new ConnectionAbstract();
|
new ConnectionAbstract();
|
||||||
}).to.throwError(TypeError);
|
}).to.throwError(TypeError);
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const conn = new ConnectionAbstract({});
|
new ConnectionAbstract({});
|
||||||
}).to.throwError(TypeError);
|
}).to.throwError(TypeError);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ function makeLogger(parent, levels) {
|
|||||||
return new ConsoleLogger(parent, config);
|
return new ConsoleLogger(parent, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
const stub = require('../../utils/auto_release_stub').make();
|
require('../../utils/auto_release_stub').make();
|
||||||
|
|
||||||
describe('Console Logger', function () {
|
describe('Console Logger', function () {
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ describe('File Logger', function () {
|
|||||||
once.call(process, event, handler);
|
once.call(process, event, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
const logger = makeLogger();
|
makeLogger();
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
// call the event handler
|
// call the event handler
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
const Host = require('../../../src/lib/host');
|
const Host = require('../../../src/lib/host');
|
||||||
const _ = require('lodash');
|
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const expectSubObject = require('../../utils/expect_sub_object');
|
const expectSubObject = require('../../utils/expect_sub_object');
|
||||||
|
|||||||
@ -3,15 +3,12 @@ describe('Http Connector', function () {
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
const nock = require('nock');
|
const nock = require('nock');
|
||||||
const sinon = require('sinon');
|
|
||||||
const util = require('util');
|
|
||||||
const parseUrl = require('url').parse;
|
const parseUrl = require('url').parse;
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const AgentKeepAlive = require('agentkeepalive');
|
const AgentKeepAlive = require('agentkeepalive');
|
||||||
|
|
||||||
const Host = require('../../../src/lib/host');
|
const Host = require('../../../src/lib/host');
|
||||||
const errors = require('../../../src/lib/errors');
|
|
||||||
const HttpConnection = require('../../../src/lib/connectors/http');
|
const HttpConnection = require('../../../src/lib/connectors/http');
|
||||||
const ConnectionAbstract = require('../../../src/lib/connection');
|
const ConnectionAbstract = require('../../../src/lib/connection');
|
||||||
|
|
||||||
@ -62,7 +59,7 @@ describe('Http Connector', function () {
|
|||||||
|
|
||||||
it('expects the host to have a protocol of http or https', function () {
|
it('expects the host to have a protocol of http or https', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const con = new HttpConnection(new Host('thrifty://es.com/stuff'));
|
new HttpConnection(new Host('thrifty://es.com/stuff'));
|
||||||
}).to.throwError(/invalid protocol/i);
|
}).to.throwError(/invalid protocol/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -254,7 +251,7 @@ describe('Http Connector', function () {
|
|||||||
stub(con.log, 'error');
|
stub(con.log, 'error');
|
||||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function () {
|
||||||
expect(con.log.error.callCount).to.eql(0);
|
expect(con.log.error.callCount).to.eql(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -264,7 +261,7 @@ describe('Http Connector', function () {
|
|||||||
const con = new HttpConnection(new Host('https://google.com'));
|
const con = new HttpConnection(new Host('https://google.com'));
|
||||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody(new Error('no more message :(')));
|
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody(new Error('no more message :(')));
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function (err) {
|
||||||
expect(err).to.be.an(Error);
|
expect(err).to.be.an(Error);
|
||||||
expect(err.message).to.eql('no more message :(');
|
expect(err.message).to.eql('no more message :(');
|
||||||
done();
|
done();
|
||||||
@ -275,7 +272,7 @@ describe('Http Connector', function () {
|
|||||||
const con = new HttpConnection(new Host('https://google.com'));
|
const con = new HttpConnection(new Host('https://google.com'));
|
||||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function (err, resp) {
|
||||||
expect(resp).to.be(undefined);
|
expect(resp).to.be(undefined);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -414,7 +411,7 @@ describe('Http Connector', function () {
|
|||||||
stub(http.ClientRequest.prototype, 'setNoDelay');
|
stub(http.ClientRequest.prototype, 'setNoDelay');
|
||||||
const server = nock('http://localhost').get('/').reply(200);
|
const server = nock('http://localhost').get('/').reply(200);
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function () {
|
||||||
expect(http.ClientRequest.prototype.setNoDelay.callCount).to.eql(1);
|
expect(http.ClientRequest.prototype.setNoDelay.callCount).to.eql(1);
|
||||||
expect(http.ClientRequest.prototype.setNoDelay.lastCall.args[0]).to.eql(true);
|
expect(http.ClientRequest.prototype.setNoDelay.lastCall.args[0]).to.eql(true);
|
||||||
server.done();
|
server.done();
|
||||||
@ -433,7 +430,7 @@ describe('Http Connector', function () {
|
|||||||
|
|
||||||
con.request({
|
con.request({
|
||||||
body: body
|
body: body
|
||||||
}, function (err, resp, status) {
|
}, function () {
|
||||||
expect(http.ClientRequest.prototype.setHeader.lastCall.args).to.eql(['Content-Length', 14]);
|
expect(http.ClientRequest.prototype.setHeader.lastCall.args).to.eql(['Content-Length', 14]);
|
||||||
server.done();
|
server.done();
|
||||||
done();
|
done();
|
||||||
@ -449,7 +446,7 @@ describe('Http Connector', function () {
|
|||||||
.once()
|
.once()
|
||||||
.reply(200, respBody);
|
.reply(200, respBody);
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function (err, resp) {
|
||||||
expect(resp).to.be(respBody);
|
expect(resp).to.be(respBody);
|
||||||
server.done();
|
server.done();
|
||||||
done();
|
done();
|
||||||
@ -465,7 +462,7 @@ describe('Http Connector', function () {
|
|||||||
.once()
|
.once()
|
||||||
.reply(200, respBody);
|
.reply(200, respBody);
|
||||||
|
|
||||||
con.request({}, function (err, resp, status) {
|
con.request({}, function (err, resp) {
|
||||||
expect(resp).to.be(respBody);
|
expect(resp).to.be(respBody);
|
||||||
server.done();
|
server.done();
|
||||||
done();
|
done();
|
||||||
|
|||||||
@ -134,7 +134,7 @@ describe('Log class', function () {
|
|||||||
log = new Log({
|
log = new Log({
|
||||||
log: [
|
log: [
|
||||||
{
|
{
|
||||||
type: function (log, config) {
|
type: function (log) {
|
||||||
log.on('error', _.noop);
|
log.on('error', _.noop);
|
||||||
log.on('warning', _.noop);
|
log.on('warning', _.noop);
|
||||||
log.on('info', _.noop);
|
log.on('info', _.noop);
|
||||||
@ -237,22 +237,22 @@ describe('Log class', function () {
|
|||||||
|
|
||||||
it('rejects numbers and other truthy data-types', function () {
|
it('rejects numbers and other truthy data-types', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: 1515 });
|
new Log({ log: 1515 });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: /regexp/ });
|
new Log({ log: /regexp/ });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: new Date() });
|
new Log({ log: new Date() });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: [1515] });
|
new Log({ log: [1515] });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: [/regexp/] });
|
new Log({ log: [/regexp/] });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const log = new Log({ log: [new Date()] });
|
new Log({ log: [new Date()] });
|
||||||
}).to.throwError(/invalid logging output config/i);
|
}).to.throwError(/invalid logging output config/i);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -31,7 +31,6 @@ describe('Stdio Logger', function () {
|
|||||||
const now = '2013-01-01T00:00:00Z';
|
const now = '2013-01-01T00:00:00Z';
|
||||||
const nowDate = new Date(now);
|
const nowDate = new Date(now);
|
||||||
const nowTime = nowDate.getTime();
|
const nowTime = nowDate.getTime();
|
||||||
let clock;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
stub.autoRelease(sinon.useFakeTimers(nowTime));
|
stub.autoRelease(sinon.useFakeTimers(nowTime));
|
||||||
|
|||||||
@ -77,7 +77,7 @@ describe('Stream Logger', function () {
|
|||||||
once.call(process, event, handler);
|
once.call(process, event, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
const logger = makeLogger();
|
makeLogger();
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
// call the event handler
|
// call the event handler
|
||||||
|
|||||||
@ -2,7 +2,6 @@ describe('Tracer Logger', function () {
|
|||||||
|
|
||||||
const Log = require('../../../src/lib/log');
|
const Log = require('../../../src/lib/log');
|
||||||
const TracerLogger = require('../../../src/lib/loggers/tracer');
|
const TracerLogger = require('../../../src/lib/loggers/tracer');
|
||||||
const sinon = require('sinon');
|
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
let parentLog;
|
let parentLog;
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@ describe('Transport Class', function () {
|
|||||||
|
|
||||||
it('Throws an error when connectionPool config is set wrong', function () {
|
it('Throws an error when connectionPool config is set wrong', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const trans = new Transport({
|
new Transport({
|
||||||
connectionPool: 'pasta'
|
connectionPool: 'pasta'
|
||||||
});
|
});
|
||||||
}).to.throwError(/invalid connectionpool/i);
|
}).to.throwError(/invalid connectionpool/i);
|
||||||
@ -166,7 +166,7 @@ describe('Transport Class', function () {
|
|||||||
describe('host config', function () {
|
describe('host config', function () {
|
||||||
it('rejects non-strings/objects', function () {
|
it('rejects non-strings/objects', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const trans = new Transport({
|
new Transport({
|
||||||
host: [
|
host: [
|
||||||
'localhost',
|
'localhost',
|
||||||
9393
|
9393
|
||||||
@ -175,7 +175,7 @@ describe('Transport Class', function () {
|
|||||||
}).to.throwError(TypeError);
|
}).to.throwError(TypeError);
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
const trans = new Transport({
|
new Transport({
|
||||||
host: [
|
host: [
|
||||||
[9292]
|
[9292]
|
||||||
]
|
]
|
||||||
@ -288,7 +288,7 @@ describe('Transport Class', function () {
|
|||||||
const _ = require('../../../src/lib/utils');
|
const _ = require('../../../src/lib/utils');
|
||||||
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
||||||
stub(_, 'shuffle');
|
stub(_, 'shuffle');
|
||||||
const trans = new Transport({
|
new Transport({
|
||||||
hosts: 'localhost'
|
hosts: 'localhost'
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ describe('Transport Class', function () {
|
|||||||
const _ = require('../../../src/lib/utils');
|
const _ = require('../../../src/lib/utils');
|
||||||
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
||||||
stub(_, 'shuffle');
|
stub(_, 'shuffle');
|
||||||
const trans = new Transport({
|
new Transport({
|
||||||
hosts: 'localhost',
|
hosts: 'localhost',
|
||||||
randomizeHosts: false
|
randomizeHosts: false
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
const Transport = require('../../../src/lib/transport');
|
const Transport = require('../../../src/lib/transport');
|
||||||
const ConnectionPool = require('../../../src/lib/connection_pool');
|
const ConnectionPool = require('../../../src/lib/connection_pool');
|
||||||
const Host = require('../../../src/lib/host');
|
|
||||||
const errors = require('../../../src/lib/errors');
|
const errors = require('../../../src/lib/errors');
|
||||||
const expect = require('expect.js');
|
const expect = require('expect.js');
|
||||||
|
|
||||||
@ -10,21 +9,6 @@ const through2 = require('through2');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const stub = require('../../utils/auto_release_stub').make();
|
const stub = require('../../utils/auto_release_stub').make();
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the tests call #request() without it doing anything past trying to select
|
|
||||||
* a connection.
|
|
||||||
* @param {Transport} tran - the transport to neuter
|
|
||||||
*/
|
|
||||||
function shortCircuitRequest(tran, delay) {
|
|
||||||
stub(tran.connectionPool, 'select', function (cb) {
|
|
||||||
setTimeout(cb, delay);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getConnection(transport, status) {
|
|
||||||
return transport.connectionPool.getConnections(status || 'alive', 1).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Transport + Mock server', function () {
|
describe('Transport + Mock server', function () {
|
||||||
describe('#request', function () {
|
describe('#request', function () {
|
||||||
describe('server responds', function () {
|
describe('server responds', function () {
|
||||||
@ -209,7 +193,7 @@ describe('Transport + Mock server', function () {
|
|||||||
|
|
||||||
trans.request({
|
trans.request({
|
||||||
path: '/',
|
path: '/',
|
||||||
}, function (err, body, status) {
|
}, function (err, body) {
|
||||||
expect(err).to.be(undefined);
|
expect(err).to.be(undefined);
|
||||||
expect(body).to.eql({
|
expect(body).to.eql({
|
||||||
'the answer': 42
|
'the answer': 42
|
||||||
@ -228,7 +212,7 @@ describe('Transport + Mock server', function () {
|
|||||||
|
|
||||||
trans.request({
|
trans.request({
|
||||||
path: '/hottie-threads',
|
path: '/hottie-threads',
|
||||||
}, function (err, body, status) {
|
}, function (err, body) {
|
||||||
expect(err).to.be(undefined);
|
expect(err).to.be(undefined);
|
||||||
expect(body).to.match(/s?he said/g);
|
expect(body).to.match(/s?he said/g);
|
||||||
done();
|
done();
|
||||||
@ -239,7 +223,7 @@ describe('Transport + Mock server', function () {
|
|||||||
|
|
||||||
describe('return value', function () {
|
describe('return value', function () {
|
||||||
it('resolves the promise it with the response body', function (done) {
|
it('resolves the promise it with the response body', function (done) {
|
||||||
const serverMock = nock('http://esbox.1.com')
|
nock('http://esbox.1.com')
|
||||||
.get('/')
|
.get('/')
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
good: 'day'
|
good: 'day'
|
||||||
@ -266,7 +250,7 @@ describe('Transport + Mock server', function () {
|
|||||||
host: 'http://localhost:9200'
|
host: 'http://localhost:9200'
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = nock('http://localhost:9200')
|
nock('http://localhost:9200')
|
||||||
.get('/')
|
.get('/')
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
i: 'am here'
|
i: 'am here'
|
||||||
@ -286,7 +270,7 @@ describe('Transport + Mock server', function () {
|
|||||||
host: 'http://localhost:9200'
|
host: 'http://localhost:9200'
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = nock('http://localhost:9200')
|
nock('http://localhost:9200')
|
||||||
.get('/')
|
.get('/')
|
||||||
.delay(1000)
|
.delay(1000)
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
@ -295,7 +279,7 @@ describe('Transport + Mock server', function () {
|
|||||||
|
|
||||||
tran.request({
|
tran.request({
|
||||||
requestTimeout: 25
|
requestTimeout: 25
|
||||||
}, function (err, resp, status) {
|
}, function (err) {
|
||||||
expect(err).to.be.a(errors.RequestTimeout);
|
expect(err).to.be.a(errors.RequestTimeout);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -307,7 +291,7 @@ describe('Transport + Mock server', function () {
|
|||||||
const clock = sinon.useFakeTimers('setTimeout');
|
const clock = sinon.useFakeTimers('setTimeout');
|
||||||
stub.autoRelease(clock);
|
stub.autoRelease(clock);
|
||||||
|
|
||||||
const serverMock = nock('http://esbox.1.com')
|
nock('http://esbox.1.com')
|
||||||
.get('/')
|
.get('/')
|
||||||
.reply(200, function () {
|
.reply(200, function () {
|
||||||
const str = through2(function (chunk, enc, cb) {
|
const str = through2(function (chunk, enc, cb) {
|
||||||
@ -338,7 +322,7 @@ describe('Transport + Mock server', function () {
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
throw new Error('expected the request to fail');
|
throw new Error('expected the request to fail');
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function () {
|
||||||
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
||||||
expect(tran.sniff.callCount).to.eql(0);
|
expect(tran.sniff.callCount).to.eql(0);
|
||||||
expect(_.size(clock.timers)).to.eql(1);
|
expect(_.size(clock.timers)).to.eql(1);
|
||||||
|
|||||||
@ -40,9 +40,6 @@ function JenkinsReporter(runner) {
|
|||||||
Base.call(this, runner);
|
Base.call(this, runner);
|
||||||
|
|
||||||
const stats = this.stats;
|
const stats = this.stats;
|
||||||
let pass = 0;
|
|
||||||
let pending = 0;
|
|
||||||
let fail = 0;
|
|
||||||
const rootSuite = {
|
const rootSuite = {
|
||||||
results: [],
|
results: [],
|
||||||
suites: []
|
suites: []
|
||||||
@ -94,14 +91,11 @@ function JenkinsReporter(runner) {
|
|||||||
|
|
||||||
runner.on('test end', function (test) {
|
runner.on('test end', function (test) {
|
||||||
if (test.state === 'passed') {
|
if (test.state === 'passed') {
|
||||||
pass++;
|
|
||||||
log(chalk.green('.'));
|
log(chalk.green('.'));
|
||||||
} else if (test.pending) {
|
} else if (test.pending) {
|
||||||
pending++;
|
|
||||||
log(chalk.grey('.'));
|
log(chalk.grey('.'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
fail++;
|
|
||||||
log(chalk.red('x'));
|
log(chalk.red('x'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user