use eslint autofix to start fixing violations

This commit is contained in:
spalger
2017-06-14 18:48:24 -07:00
parent da8e558817
commit 3d75c6ff0f
97 changed files with 1281 additions and 1280 deletions

View File

@ -1,10 +1,10 @@
var Host = require('../../../src/lib/host');
var _ = require('lodash');
var expect = require('expect.js');
var url = require('url');
var expectSubObject = require('../../utils/expect_sub_object');
const Host = require('../../../src/lib/host');
const _ = require('lodash');
const expect = require('expect.js');
const url = require('url');
const expectSubObject = require('../../utils/expect_sub_object');
var hostDefaults = {
const hostDefaults = {
protocol: 'http',
host: 'localhost',
port: 9200,
@ -24,20 +24,20 @@ var hostDefaults = {
}
};
var base64 = function (str) {
var buffer = Buffer.from ? Buffer.from(str, 'utf8') : new Buffer(str, 'utf8')
return buffer.toString('base64')
}
const base64 = function (str) {
const buffer = Buffer.from ? Buffer.from(str, 'utf8') : new Buffer(str, 'utf8');
return buffer.toString('base64');
};
describe('Host class', function () {
describe('construction', function () {
it('properly sets the defaults', function () {
var host = new Host();
const host = new Host();
expect(host).to.eql(hostDefaults);
});
it('accepts a string for query', function () {
var host = new Host({ query: 'beep=boop' });
const host = new Host({ query: 'beep=boop' });
expect(host.query).to.eql({
beep: 'boop'
@ -45,15 +45,15 @@ describe('Host class', function () {
});
it('accepts other generic params', function () {
var headers = { 'X-Special-Routing-Header': 'pie' };
var host = new Host({ headers: headers });
const headers = { 'X-Special-Routing-Header': 'pie' };
const host = new Host({ headers: headers });
expect(host.headers).to.eql(headers);
});
describe('from a string', function () {
it('accepts a string for the entire url', function () {
var host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true');
const host = new Host('john:dude@pizza.com:420/pizza/cheese?shrooms=true');
expectSubObject(host, {
protocol: 'http',
@ -67,7 +67,7 @@ describe('Host class', function () {
});
it('uses the default port based on the protocol', function () {
var host;
let host;
host = new Host('https://google.com');
expect(host.port).to.be(443);
@ -82,7 +82,7 @@ describe('Host class', function () {
});
it('parses simple urls properly', function () {
var host;
let host;
host = new Host('localhost');
expect(host.host).to.be('localhost');
@ -108,19 +108,19 @@ describe('Host class', function () {
describe('based on the output from url.parse', function () {
it('might cause weird things to happen', function () {
var parsedUrl = url.parse('pizza.com:888');
const parsedUrl = url.parse('pizza.com:888');
// I imagine most people don't expect
expect(parsedUrl.protocol).to.eql('pizza.com:');
expect(parsedUrl.host).to.eql('888');
var host = new Host(parsedUrl);
const host = new Host(parsedUrl);
expect(host.protocol).to.eql('pizza.com');
expect(host.host).to.eql('888');
});
it('will cause extra properties', function () {
var host = new Host(url.parse('https://joe:diner@pizza.com:888/path?query=yes#section'));
const host = new Host(url.parse('https://joe:diner@pizza.com:888/path?query=yes#section'));
expect(host.protocol).to.eql('https');
expect(host.host).to.eql('pizza.com');
expect(host.port).to.eql(888);
@ -135,13 +135,13 @@ describe('Host class', function () {
});
it('ignores anything that\'s not a string or object-y', function () {
var host = new Host(1234);
const host = new Host(1234);
expect(host).to.eql(hostDefaults);
});
it('defaults auth values from the `httpAuth` setting', function () {
var host = new Host('http://localhost:9200', {
const host = new Host('http://localhost:9200', {
httpAuth: 'username:password'
});
@ -151,7 +151,7 @@ describe('Host class', function () {
describe('#makeUrl', function () {
it('merges parameters', function () {
var host = new Host({
const host = new Host({
path: '/prefix',
query: {
user_id: 123
@ -167,7 +167,7 @@ describe('Host class', function () {
});
it('ensures that path starts with a forward-slash', function () {
var host = new Host();
const host = new Host();
host.path = 'prefix';
expect(host.makeUrl({ path: '/this and that' }))
@ -175,14 +175,14 @@ describe('Host class', function () {
});
it('does not try to prevent double forward-slashes', function () {
var host = new Host({ path: 'prefix/' });
const host = new Host({ path: 'prefix/' });
expect(host.makeUrl({ path: '/this and that' }))
.to.be('http://localhost:9200/prefix//this and that');
});
it('creates proper url without any params', function () {
var host = new Host({});
let host = new Host({});
expect(host.makeUrl()).to.be('http://localhost:9200/');
host = new Host({ host: 'john', port: 80 });
@ -193,7 +193,7 @@ describe('Host class', function () {
});
it('outputs valid relative urls when the host is empty', function () {
var host = new Host({
const host = new Host({
host: false,
path: '/path',
query: { this: 'that' }
@ -205,7 +205,7 @@ describe('Host class', function () {
describe('#toString', function () {
it('produces the same output as makeUrl when it is called without params', function () {
var host = new Host({
const host = new Host({
path: '/pasta',
host: 'google.com'
});
@ -216,7 +216,7 @@ describe('Host class', function () {
describe('#getHeaders', function () {
it('merges the passed in headers with the default headers', function () {
var host = new Host({ headers: { 'Joe-Smith': 'present' } });
const host = new Host({ headers: { 'Joe-Smith': 'present' } });
expect(host.getHeaders({
'John-Smith': 'present'
@ -227,7 +227,7 @@ describe('Host class', function () {
});
it('overrides the default headers with the passed in headers', function () {
var host = new Host({ headers: { 'Joe-Smith': 'present' } });
const host = new Host({ headers: { 'Joe-Smith': 'present' } });
expect(host.getHeaders({
'John-Smith': 'present',
@ -239,7 +239,7 @@ describe('Host class', function () {
});
it('adds Accept-Encoding header when the suggestCompression setting is true', function () {
var host = new Host({ suggestCompression: true });
const host = new Host({ suggestCompression: true });
expect(host.getHeaders()).to.eql({
'Accept-Encoding': 'gzip,deflate'
});