From 154cd5a5d737a712178abf1e0a44cdac5393ca20 Mon Sep 17 00:00:00 2001 From: Tyler Stewart Date: Mon, 30 Oct 2017 17:17:08 -0600 Subject: [PATCH] chore: eslint --fix --- config/testUnit/istanbul.js | 35 ------------------- config/testUnit/thresholds.json | 14 -------- package.json | 4 +-- src/commands/index.js | 2 +- src/commands/registration/port.js | 1 + src/commands/registration/site/index.js | 2 +- src/connector/active.js | 2 +- src/connector/passive.js | 2 +- src/fs.js | 2 +- src/index.js | 2 +- test/commands/registration/auth.spec.js | 6 ++-- test/commands/registration/cwd.spec.js | 12 +++---- test/commands/registration/dele.spec.js | 10 +++--- test/commands/registration/help.spec.js | 8 ++--- test/commands/registration/list.spec.js | 4 +-- test/commands/registration/mdtm.spec.js | 6 ++-- test/commands/registration/mkd.spec.js | 6 ++-- test/commands/registration/pass.spec.js | 2 +- test/commands/registration/port.spec.js | 4 +-- test/commands/registration/pwd.spec.js | 8 ++--- test/commands/registration/rest.spec.js | 8 ++--- test/commands/registration/retr.spec.js | 4 +-- test/commands/registration/rnfr.spec.js | 8 ++--- test/commands/registration/rnto.spec.js | 8 ++--- test/commands/registration/site/chmod.spec.js | 8 ++--- test/commands/registration/size.spec.js | 8 ++--- test/commands/registration/stat.spec.js | 14 ++++---- test/commands/registration/stor.spec.js | 4 +-- test/commands/registration/stou.spec.js | 4 +-- test/commands/registration/stru.spec.js | 4 +-- test/commands/registration/type.spec.js | 8 ++--- test/commands/registration/user.spec.js | 18 +++++----- test/connector/active.spec.js | 2 +- test/connector/passive.spec.js | 2 +- test/mochabunyan.opts | 5 --- test/start.js | 2 +- 36 files changed, 93 insertions(+), 146 deletions(-) delete mode 100644 config/testUnit/istanbul.js delete mode 100644 config/testUnit/thresholds.json delete mode 100644 test/mochabunyan.opts diff --git a/config/testUnit/istanbul.js b/config/testUnit/istanbul.js deleted file mode 100644 index aecbbdab..00000000 --- a/config/testUnit/istanbul.js +++ /dev/null @@ -1,35 +0,0 @@ -// Use JS to support loading of threshold data from external file -var coverageConfig = { - instrumentation: { - root: 'src/', - excludes: ['errors.js'] - }, - check: require('./thresholds.json'), - reporting: { - print: 'both', - dir: 'reports/coverage/', - reports: [ - 'cobertura', - 'html', - 'lcovonly', - 'html', - 'json' - ], - 'report-config': { - cobertura: { - file: 'cobertura/coverage.xml' - }, - json: { - file: 'json/coverage.json' - }, - lcovonly: { - file: 'lcov/lcov.info' - }, - text: { - file: null - } - } - } -}; - -module.exports = coverageConfig; diff --git a/config/testUnit/thresholds.json b/config/testUnit/thresholds.json deleted file mode 100644 index cba363f2..00000000 --- a/config/testUnit/thresholds.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "global": { - "statements": 90, - "branches": 80, - "functions": 90, - "lines": 90 - }, - "each": { - "statements": 70, - "branches": 40, - "functions": 60, - "lines": 70 - } -} diff --git a/package.json b/package.json index 1136f1fe..19cb36bf 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "test:unit:once": "cross-env NODE_ENV=test nyc mocha --opts config/testUnit/mocha.opts", "upload-coverage": "cat reports/coverage/lcov.info | coveralls", "verify": "npm run verify:js --silent", - "verify:js": "eslint -c config/verify/.eslintrc.js \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js success", - "verify:js:fix": "eslint --fix -c config/verify/.eslintrc.js \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js:fix success", + "verify:js": "eslint -c config/verify/.eslintrc \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js success", + "verify:js:fix": "eslint --fix -c config/verify/.eslintrc \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js:fix success", "verify:js:watch": "chokidar 'src/**/*.js' 'test/**/*.js' 'config/**/*.js' -c 'npm run verify:js:fix' --initial --silent", "verify:watch": "npm run verify:js:watch --silent" }, diff --git a/src/commands/index.js b/src/commands/index.js index aac21506..a23ce547 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -62,7 +62,7 @@ class FtpCommands { } const handler = commandRegister.handler.bind(this.connection); - return when.try(handler, { log, command, previous_command: this.previousCommand }) + return when.try(handler, {log, command, previous_command: this.previousCommand}) .finally(() => { this.previousCommand = _.clone(command); }); diff --git a/src/commands/registration/port.js b/src/commands/registration/port.js index d53dd377..80663d58 100644 --- a/src/commands/registration/port.js +++ b/src/commands/registration/port.js @@ -5,6 +5,7 @@ module.exports = { directive: 'PORT', handler: function ({command} = {}) { this.connector = new ActiveConnector(this); + const rawConnection = _.get(command, 'arg', '').split(','); if (rawConnection.length !== 6) return this.reply(425); diff --git a/src/commands/registration/site/index.js b/src/commands/registration/site/index.js index efed6647..521a0f59 100644 --- a/src/commands/registration/site/index.js +++ b/src/commands/registration/site/index.js @@ -10,7 +10,7 @@ module.exports = { if (!registry.hasOwnProperty(subCommand.directive)) return this.reply(502); const handler = registry[subCommand.directive].handler.bind(this); - return when.try(handler, { log: subLog, command: subCommand }); + return when.try(handler, {log: subLog, command: subCommand}); }, syntax: '{{cmd}} [...]', description: 'Sends site specific commands to remote server' diff --git a/src/connector/active.js b/src/connector/active.js index 1de092db..8938e1f4 100644 --- a/src/connector/active.js +++ b/src/connector/active.js @@ -28,7 +28,7 @@ class Active extends Connector { this.dataSocket = new Socket(); this.dataSocket.setEncoding(this.connection.transferType); this.dataSocket.on('error', err => this.server.emit('client-error', {connection: this.connection, context: 'dataSocket', error: err})); - this.dataSocket.connect({ host, port, family }, () => { + this.dataSocket.connect({host, port, family}, () => { this.dataSocket.pause(); if (this.connection.secure) { diff --git a/src/connector/passive.js b/src/connector/passive.js index eb0ae73c..b1ee53a2 100644 --- a/src/connector/passive.js +++ b/src/connector/passive.js @@ -63,7 +63,7 @@ class Passive extends Connector { }; this.dataSocket = null; - this.dataServer = net.createServer({ pauseOnConnect: true }, connectionHandler); + this.dataServer = net.createServer({pauseOnConnect: true}, connectionHandler); this.dataServer.maxConnections = 1; this.dataServer.on('error', err => this.server.emit('client-error', {connection: this.connection, context: 'dataServer', error: err})); this.dataServer.on('close', () => { diff --git a/src/fs.js b/src/fs.js index b14df76a..05e00512 100644 --- a/src/fs.js +++ b/src/fs.js @@ -8,7 +8,7 @@ const fs = whenNode.liftAll(syncFs); const errors = require('./errors'); class FileSystem { - constructor(connection, { root, cwd } = {}) { + constructor(connection, {root, cwd} = {}) { this.connection = connection; this.cwd = cwd || nodePath.sep; this.root = root || process.cwd(); diff --git a/src/index.js b/src/index.js index 5d6bb61e..330ae9c9 100644 --- a/src/index.js +++ b/src/index.js @@ -43,7 +43,7 @@ class FtpServer { return connection.reply(220, ...greeting, features) .finally(() => socket.resume()); }; - const serverOptions = _.assign(this.isTLS ? this._tls : {}, { pauseOnConnect: true }); + const serverOptions = _.assign(this.isTLS ? this._tls : {}, {pauseOnConnect: true}); this.server = (this.isTLS ? tls : net).createServer(serverOptions, serverConnectionHandler); this.server.on('error', err => this.log.error(err, '[Event] error')); diff --git a/test/commands/registration/auth.spec.js b/test/commands/registration/auth.spec.js index 9401b062..a7919160 100644 --- a/test/commands/registration/auth.spec.js +++ b/test/commands/registration/auth.spec.js @@ -23,7 +23,7 @@ describe(CMD, function () { }); it('TLS // supported', () => { - return cmdFn({command: { arg: 'TLS', directive: CMD}}) + return cmdFn({command: {arg: 'TLS', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(234); expect(mockClient.secure).to.equal(true); @@ -31,14 +31,14 @@ describe(CMD, function () { }); it('SSL // not supported', () => { - return cmdFn({command: { arg: 'SSL', directive: CMD}}) + return cmdFn({command: {arg: 'SSL', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(504); }); }); it('bad // bad', () => { - return cmdFn({command: { arg: 'bad', directive: CMD}}) + return cmdFn({command: {arg: 'bad', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(504); }); diff --git a/test/commands/registration/cwd.spec.js b/test/commands/registration/cwd.spec.js index 73ed1233..6f018fda 100644 --- a/test/commands/registration/cwd.spec.js +++ b/test/commands/registration/cwd.spec.js @@ -8,7 +8,7 @@ describe(CMD, function () { let log = bunyan.createLogger({name: CMD}); const mockClient = { reply: () => {}, - fs: { chdir: () => {} } + fs: {chdir: () => {}} }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -24,7 +24,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -35,7 +35,7 @@ describe(CMD, function () { }); it('fails on no fs chdir command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -47,7 +47,7 @@ describe(CMD, function () { }); it('test // successful', () => { - return cmdFn({log, command: { arg: 'test', directive: CMD}}) + return cmdFn({log, command: {arg: 'test', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(250); expect(mockClient.fs.chdir.args[0][0]).to.equal('test'); @@ -58,7 +58,7 @@ describe(CMD, function () { mockClient.fs.chdir.restore(); sandbox.stub(mockClient.fs, 'chdir').resolves('/test'); - return cmdFn({log, command: { arg: 'test', directive: CMD}}) + return cmdFn({log, command: {arg: 'test', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(250); expect(mockClient.fs.chdir.args[0][0]).to.equal('test'); @@ -69,7 +69,7 @@ describe(CMD, function () { mockClient.fs.chdir.restore(); sandbox.stub(mockClient.fs, 'chdir').rejects(new Error('Bad')); - return cmdFn({log, command: { arg: 'bad', directive: CMD}}) + return cmdFn({log, command: {arg: 'bad', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); expect(mockClient.fs.chdir.args[0][0]).to.equal('bad'); diff --git a/test/commands/registration/dele.spec.js b/test/commands/registration/dele.spec.js index 0a4130f9..c4535555 100644 --- a/test/commands/registration/dele.spec.js +++ b/test/commands/registration/dele.spec.js @@ -8,7 +8,7 @@ describe(CMD, function () { let log = bunyan.createLogger({name: CMD}); const mockClient = { reply: () => {}, - fs: { delete: () => {} } + fs: {delete: () => {}} }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -24,7 +24,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -35,7 +35,7 @@ describe(CMD, function () { }); it('fails on no fs delete command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -47,7 +47,7 @@ describe(CMD, function () { }); it('test // successful', () => { - return cmdFn({log, command: { arg: 'test', directive: CMD}}) + return cmdFn({log, command: {arg: 'test', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(250); expect(mockClient.fs.delete.args[0][0]).to.equal('test'); @@ -58,7 +58,7 @@ describe(CMD, function () { mockClient.fs.delete.restore(); sandbox.stub(mockClient.fs, 'delete').rejects(new Error('Bad')); - return cmdFn({log, command: { arg: 'bad', directive: CMD}}) + return cmdFn({log, command: {arg: 'bad', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); expect(mockClient.fs.delete.args[0][0]).to.equal('bad'); diff --git a/test/commands/registration/help.spec.js b/test/commands/registration/help.spec.js index 2e83e3a7..97adcd47 100644 --- a/test/commands/registration/help.spec.js +++ b/test/commands/registration/help.spec.js @@ -20,28 +20,28 @@ describe(CMD, function () { }); it('// successful', () => { - return cmdFn({command: { directive: CMD }}) + return cmdFn({command: {directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(211); }); }); it('help // successful', () => { - return cmdFn({command: { arg: 'help', directive: CMD}}) + return cmdFn({command: {arg: 'help', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(214); }); }); it('allo // successful', () => { - return cmdFn({command: { arg: 'allo', directive: CMD}}) + return cmdFn({command: {arg: 'allo', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(214); }); }); it('bad // unsuccessful', () => { - return cmdFn({command: { arg: 'bad', directive: CMD}}) + return cmdFn({command: {arg: 'bad', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(502); }); diff --git a/test/commands/registration/list.spec.js b/test/commands/registration/list.spec.js index 9da7f99f..a9e27ded 100644 --- a/test/commands/registration/list.spec.js +++ b/test/commands/registration/list.spec.js @@ -88,7 +88,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -99,7 +99,7 @@ describe(CMD, function () { }); it('fails on no fs list command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); diff --git a/test/commands/registration/mdtm.spec.js b/test/commands/registration/mdtm.spec.js index a7ef52f4..08387831 100644 --- a/test/commands/registration/mdtm.spec.js +++ b/test/commands/registration/mdtm.spec.js @@ -8,7 +8,7 @@ describe(CMD, function () { let log = bunyan.createLogger({name: CMD}); const mockClient = { reply: () => {}, - fs: { get: () => {} } + fs: {get: () => {}} }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -24,7 +24,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -35,7 +35,7 @@ describe(CMD, function () { }); it('fails on no fs get command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); diff --git a/test/commands/registration/mkd.spec.js b/test/commands/registration/mkd.spec.js index 6849498a..2303db2f 100644 --- a/test/commands/registration/mkd.spec.js +++ b/test/commands/registration/mkd.spec.js @@ -8,7 +8,7 @@ describe(CMD, function () { let log = bunyan.createLogger({name: CMD}); const mockClient = { reply: () => {}, - fs: { mkdir: () => {} } + fs: {mkdir: () => {}} }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -24,7 +24,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -35,7 +35,7 @@ describe(CMD, function () { }); it('fails on no fs mkdir command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); diff --git a/test/commands/registration/pass.spec.js b/test/commands/registration/pass.spec.js index b1d53230..d0d54154 100644 --- a/test/commands/registration/pass.spec.js +++ b/test/commands/registration/pass.spec.js @@ -9,7 +9,7 @@ describe(CMD, function () { const mockClient = { reply: () => {}, login: () => {}, - server: { options: { anonymous: false } }, + server: {options: {anonymous: false}}, username: 'anonymous' }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); diff --git a/test/commands/registration/port.spec.js b/test/commands/registration/port.spec.js index fb880d52..f1f83577 100644 --- a/test/commands/registration/port.spec.js +++ b/test/commands/registration/port.spec.js @@ -30,14 +30,14 @@ describe(CMD, function () { }); it('// unsuccessful | invalid argument', () => { - return cmdFn({ command: { arg: '1,2,3,4,5' } }) + return cmdFn({command: {arg: '1,2,3,4,5'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(425); }); }); it('// successful', () => { - return cmdFn({ command: { arg: '192,168,0,100,137,214' } }) + return cmdFn({command: {arg: '192,168,0,100,137,214'}}) .then(() => { const [ip, port] = ActiveConnector.prototype.setupConnection.args[0]; expect(mockClient.reply.args[0][0]).to.equal(200); diff --git a/test/commands/registration/pwd.spec.js b/test/commands/registration/pwd.spec.js index 8f95126b..2bb40ceb 100644 --- a/test/commands/registration/pwd.spec.js +++ b/test/commands/registration/pwd.spec.js @@ -8,7 +8,7 @@ describe(CMD, function () { let log = bunyan.createLogger({name: CMD}); const mockClient = { reply: () => {}, - fs: { currentDirectory: () => {} } + fs: {currentDirectory: () => {}} }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -24,7 +24,7 @@ describe(CMD, function () { describe('// check', function () { it('fails on no fs', () => { - const badMockClient = { reply: () => {} }; + const badMockClient = {reply: () => {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -35,7 +35,7 @@ describe(CMD, function () { }); it('fails on no fs currentDirectory command', () => { - const badMockClient = { reply: () => {}, fs: {} }; + const badMockClient = {reply: () => {}, fs: {}}; const badCmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(badMockClient); sandbox.stub(badMockClient, 'reply').resolves(); @@ -47,7 +47,7 @@ describe(CMD, function () { }); it('// successful', () => { - return cmdFn({log, command: { arg: 'test', directive: CMD}}) + return cmdFn({log, command: {arg: 'test', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(257); }); diff --git a/test/commands/registration/rest.spec.js b/test/commands/registration/rest.spec.js index 17a62274..852f97be 100644 --- a/test/commands/registration/rest.spec.js +++ b/test/commands/registration/rest.spec.js @@ -27,21 +27,21 @@ describe(CMD, function () { }); it('-1 // unsuccessful', () => { - return cmdFn({command: { arg: '-1', directive: CMD } }) + return cmdFn({command: {arg: '-1', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(501); }); }); it('bad // unsuccessful', () => { - return cmdFn({command: { arg: 'bad', directive: CMD } }) + return cmdFn({command: {arg: 'bad', directive: CMD}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(501); }); }); it('1 // successful', () => { - return cmdFn({command: { arg: '1', directive: CMD } }) + return cmdFn({command: {arg: '1', directive: CMD}}) .then(() => { expect(mockClient.restByteCount).to.equal(1); expect(mockClient.reply.args[0][0]).to.equal(350); @@ -49,7 +49,7 @@ describe(CMD, function () { }); it('0 // successful', () => { - return cmdFn({command: { arg: '0', directive: CMD } }) + return cmdFn({command: {arg: '0', directive: CMD}}) .then(() => { expect(mockClient.restByteCount).to.equal(0); expect(mockClient.reply.args[0][0]).to.equal(350); diff --git a/test/commands/registration/retr.spec.js b/test/commands/registration/retr.spec.js index ff22d801..802ac4a4 100644 --- a/test/commands/registration/retr.spec.js +++ b/test/commands/registration/retr.spec.js @@ -56,7 +56,7 @@ describe(CMD, function () { return when.reject(new when.TimeoutError()); }); - return cmdFn({log, command: {arg: 'test.txt'} }) + return cmdFn({log, command: {arg: 'test.txt'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(425); }); @@ -67,7 +67,7 @@ describe(CMD, function () { return when.reject(new Error('test')); }); - return cmdFn({log, command: {arg: 'test.txt'} }) + return cmdFn({log, command: {arg: 'test.txt'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(551); }); diff --git a/test/commands/registration/rnfr.spec.js b/test/commands/registration/rnfr.spec.js index 00ae371a..a5afefa5 100644 --- a/test/commands/registration/rnfr.spec.js +++ b/test/commands/registration/rnfr.spec.js @@ -5,8 +5,8 @@ const sinon = require('sinon'); const CMD = 'RNFR'; describe(CMD, function () { let sandbox; - const mockLog = { error: () => {} }; - const mockClient = { reply: () => when.resolve() }; + const mockLog = {error: () => {}}; + const mockClient = {reply: () => when.resolve()}; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); beforeEach(() => { @@ -46,14 +46,14 @@ describe(CMD, function () { mockClient.fs.get.restore(); sandbox.stub(mockClient.fs, 'get').rejects(new Error('test')); - return cmdFn({ log: mockLog, command: { arg: 'test' } }) + return cmdFn({log: mockLog, command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); }); }); it('test // successful', () => { - return cmdFn({ log: mockLog, command: { arg: 'test' } }) + return cmdFn({log: mockLog, command: {arg: 'test'}}) .then(() => { expect(mockClient.fs.get.args[0][0]).to.equal('test'); expect(mockClient.reply.args[0][0]).to.equal(350); diff --git a/test/commands/registration/rnto.spec.js b/test/commands/registration/rnto.spec.js index bd569388..07e132fe 100644 --- a/test/commands/registration/rnto.spec.js +++ b/test/commands/registration/rnto.spec.js @@ -5,8 +5,8 @@ const sinon = require('sinon'); const CMD = 'RNTO'; describe(CMD, function () { let sandbox; - const mockLog = { error: () => {} }; - const mockClient = { reply: () => when.resolve() }; + const mockLog = {error: () => {}}; + const mockClient = {reply: () => when.resolve()}; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); beforeEach(() => { @@ -56,14 +56,14 @@ describe(CMD, function () { mockClient.fs.rename.restore(); sandbox.stub(mockClient.fs, 'rename').rejects(new Error('test')); - return cmdFn({ log: mockLog, command: { arg: 'new' } }) + return cmdFn({log: mockLog, command: {arg: 'new'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); }); }); it('new // successful', () => { - return cmdFn({ command: { arg: 'new' } }) + return cmdFn({command: {arg: 'new'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(250); expect(mockClient.fs.rename.args[0]).to.eql(['test', 'new']); diff --git a/test/commands/registration/site/chmod.spec.js b/test/commands/registration/site/chmod.spec.js index 52136182..93ca81c3 100644 --- a/test/commands/registration/site/chmod.spec.js +++ b/test/commands/registration/site/chmod.spec.js @@ -5,8 +5,8 @@ const sinon = require('sinon'); const CMD = 'CHMOD'; describe(CMD, function () { let sandbox; - const mockLog = { error: () => {} }; - const mockClient = { reply: () => when.resolve() }; + const mockLog = {error: () => {}}; + const mockClient = {reply: () => when.resolve()}; const cmdFn = require(`../../../../src/commands/registration/site/${CMD.toLowerCase()}`).bind(mockClient); beforeEach(() => { @@ -49,7 +49,7 @@ describe(CMD, function () { mockClient.fs.chmod.restore(); sandbox.stub(mockClient.fs, 'chmod').rejects(new Error('test')); - cmdFn({ log: mockLog, command: { arg: '777 test' } }) + cmdFn({log: mockLog, command: {arg: '777 test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(500); done(); @@ -58,7 +58,7 @@ describe(CMD, function () { }); it('777 test // successful', done => { - cmdFn({ log: mockLog, command: { arg: '777 test' } }) + cmdFn({log: mockLog, command: {arg: '777 test'}}) .then(() => { expect(mockClient.fs.chmod.args[0]).to.eql(['test', 511]); expect(mockClient.reply.args[0][0]).to.equal(200); diff --git a/test/commands/registration/size.spec.js b/test/commands/registration/size.spec.js index f692ca98..395ae809 100644 --- a/test/commands/registration/size.spec.js +++ b/test/commands/registration/size.spec.js @@ -5,8 +5,8 @@ const sinon = require('sinon'); const CMD = 'SIZE'; describe(CMD, function () { let sandbox; - const mockLog = { error: () => {} }; - const mockClient = { reply: () => when.resolve() }; + const mockLog = {error: () => {}}; + const mockClient = {reply: () => when.resolve()}; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); beforeEach(() => { @@ -43,14 +43,14 @@ describe(CMD, function () { it('// unsuccessful | file get fails', () => { sandbox.stub(mockClient.fs, 'get').rejects(new Error('test')); - return cmdFn({ log: mockLog, command: { arg: 'test' } }) + return cmdFn({log: mockLog, command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); }); }); it('// successful', () => { - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(213); }); diff --git a/test/commands/registration/stat.spec.js b/test/commands/registration/stat.spec.js index e69ef17e..f8021d64 100644 --- a/test/commands/registration/stat.spec.js +++ b/test/commands/registration/stat.spec.js @@ -5,8 +5,8 @@ const sinon = require('sinon'); const CMD = 'STAT'; describe(CMD, function () { let sandbox; - const mockLog = { error: () => {} }; - const mockClient = { reply: () => when.resolve() }; + const mockLog = {error: () => {}}; + const mockClient = {reply: () => when.resolve()}; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); beforeEach(() => { @@ -33,7 +33,7 @@ describe(CMD, function () { it('// unsuccessful | no file system', () => { delete mockClient.fs; - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); }); @@ -42,7 +42,7 @@ describe(CMD, function () { it('// unsuccessful | file system does not have functions', () => { mockClient.fs = {}; - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(402); }); @@ -51,7 +51,7 @@ describe(CMD, function () { it('// unsuccessful | file get fails', () => { sandbox.stub(mockClient.fs, 'get').rejects(new Error('test')); - return cmdFn({ log: mockLog, command: { arg: 'test' } }) + return cmdFn({log: mockLog, command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(450); }); @@ -77,7 +77,7 @@ describe(CMD, function () { isDirectory: () => false }); - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(212); }); @@ -122,7 +122,7 @@ describe(CMD, function () { isDirectory: () => true }); - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(213); }); diff --git a/test/commands/registration/stor.spec.js b/test/commands/registration/stor.spec.js index e8c7df17..c00b4118 100644 --- a/test/commands/registration/stor.spec.js +++ b/test/commands/registration/stor.spec.js @@ -56,7 +56,7 @@ describe(CMD, function () { return when.reject(new when.TimeoutError()); }); - return cmdFn({log, command: {arg: 'test.txt'} }) + return cmdFn({log, command: {arg: 'test.txt'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(425); }); @@ -67,7 +67,7 @@ describe(CMD, function () { return when.reject(new Error('test')); }); - return cmdFn({log, command: {arg: 'test.txt'} }) + return cmdFn({log, command: {arg: 'test.txt'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(550); }); diff --git a/test/commands/registration/stou.spec.js b/test/commands/registration/stou.spec.js index 113b9a2b..053ae9e9 100644 --- a/test/commands/registration/stou.spec.js +++ b/test/commands/registration/stou.spec.js @@ -52,7 +52,7 @@ describe(CMD, function () { mockClient.fs.get.restore(); sandbox.stub(mockClient.fs, 'get').rejects({}); - return cmdFn({ command: { arg: 'good' } }) + return cmdFn({command: {arg: 'good'}}) .then(() => { const call = stor.handler.call.args[0][1]; expect(call).to.have.property('command'); @@ -63,7 +63,7 @@ describe(CMD, function () { }); it('// successful | generates unique name', () => { - return cmdFn({ command: { arg: 'bad' } }) + return cmdFn({command: {arg: 'bad'}}) .then(() => { const call = stor.handler.call.args[0][1]; expect(call).to.have.property('command'); diff --git a/test/commands/registration/stru.spec.js b/test/commands/registration/stru.spec.js index ebd12911..ef8d2fe6 100644 --- a/test/commands/registration/stru.spec.js +++ b/test/commands/registration/stru.spec.js @@ -20,14 +20,14 @@ describe(CMD, function () { }); it('// successful', () => { - return cmdFn({command: { arg: 'F' } }) + return cmdFn({command: {arg: 'F'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(200); }); }); it('// unsuccessful', () => { - return cmdFn({command: { arg: 'X' } }) + return cmdFn({command: {arg: 'X'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(504); }); diff --git a/test/commands/registration/type.spec.js b/test/commands/registration/type.spec.js index db964d41..afe4a384 100644 --- a/test/commands/registration/type.spec.js +++ b/test/commands/registration/type.spec.js @@ -21,7 +21,7 @@ describe(CMD, function () { }); it('A // successful', () => { - return cmdFn({ command: { arg: 'A' } }) + return cmdFn({command: {arg: 'A'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(200); expect(mockClient.transferType).to.equal('ascii'); @@ -29,7 +29,7 @@ describe(CMD, function () { }); it('I // successful', () => { - return cmdFn({ command: { arg: 'I' } }) + return cmdFn({command: {arg: 'I'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(200); expect(mockClient.transferType).to.equal('binary'); @@ -37,7 +37,7 @@ describe(CMD, function () { }); it('L // successful', () => { - return cmdFn({ command: { arg: 'L' } }) + return cmdFn({command: {arg: 'L'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(200); expect(mockClient.transferType).to.equal('binary'); @@ -45,7 +45,7 @@ describe(CMD, function () { }); it('X // successful', () => { - return cmdFn({ command: { arg: 'X' } }) + return cmdFn({command: {arg: 'X'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(501); expect(mockClient.transferType).to.equal(null); diff --git a/test/commands/registration/user.spec.js b/test/commands/registration/user.spec.js index 11dc3634..dd46aea2 100644 --- a/test/commands/registration/user.spec.js +++ b/test/commands/registration/user.spec.js @@ -10,7 +10,7 @@ describe(CMD, function () { }; const mockClient = { reply: () => when.resolve(), - server: { options: {} }, + server: {options: {}}, login: () => when.resolve() }; const cmdFn = require(`../../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient); @@ -29,7 +29,7 @@ describe(CMD, function () { }); it('test // successful | prompt for password', () => { - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(331); }); @@ -38,7 +38,7 @@ describe(CMD, function () { it('test // successful | anonymous login', () => { mockClient.server.options = {anonymous: true}; - return cmdFn({ command: { arg: 'anonymous' } }) + return cmdFn({command: {arg: 'anonymous'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(230); expect(mockClient.login.callCount).to.equal(1); @@ -46,7 +46,7 @@ describe(CMD, function () { }); it('test // unsuccessful | no username provided', () => { - return cmdFn({ command: { } }) + return cmdFn({command: { }}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(501); expect(mockClient.login.callCount).to.equal(0); @@ -56,7 +56,7 @@ describe(CMD, function () { it('test // unsuccessful | already set username', () => { mockClient.username = 'test'; - return cmdFn({ command: { arg: 'test' } }) + return cmdFn({command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(530); expect(mockClient.login.callCount).to.equal(0); @@ -66,7 +66,7 @@ describe(CMD, function () { it('test // successful | regular login if anonymous is true', () => { mockClient.server.options = {anonymous: true}; - return cmdFn({ log: mockLog, command: { arg: 'test' } }) + return cmdFn({log: mockLog, command: {arg: 'test'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(331); expect(mockClient.login.callCount).to.equal(0); @@ -76,7 +76,7 @@ describe(CMD, function () { it('test // successful | anonymous login with set username', () => { mockClient.server.options = {anonymous: 'sillyrabbit'}; - return cmdFn({ log: mockLog, command: { arg: 'sillyrabbit' } }) + return cmdFn({log: mockLog, command: {arg: 'sillyrabbit'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(230); expect(mockClient.login.callCount).to.equal(1); @@ -88,7 +88,7 @@ describe(CMD, function () { mockClient.login.restore(); sandbox.stub(mockClient, 'login').rejects(new Error('test')); - return cmdFn({ log: mockLog, command: { arg: 'anonymous' } }) + return cmdFn({log: mockLog, command: {arg: 'anonymous'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(530); expect(mockClient.login.callCount).to.equal(1); @@ -98,7 +98,7 @@ describe(CMD, function () { it('test // successful | does not login if already authenticated', () => { mockClient.authenticated = true; - return cmdFn({ log: mockLog, command: { arg: 'sillyrabbit' } }) + return cmdFn({log: mockLog, command: {arg: 'sillyrabbit'}}) .then(() => { expect(mockClient.reply.args[0][0]).to.equal(230); expect(mockClient.login.callCount).to.equal(0); diff --git a/test/connector/active.spec.js b/test/connector/active.spec.js index b25a3e05..4d8ed155 100644 --- a/test/connector/active.spec.js +++ b/test/connector/active.spec.js @@ -66,7 +66,7 @@ describe('Connector - Active //', function () { it('upgrades to a secure connection', function () { mockConnection.secure = true; - mockConnection.server = { _tls: {} }; + mockConnection.server = {_tls: {}}; return active.setupConnection('127.0.0.1', PORT) .then(() => { diff --git a/test/connector/passive.spec.js b/test/connector/passive.spec.js index 783805bb..28789a66 100644 --- a/test/connector/passive.spec.js +++ b/test/connector/passive.spec.js @@ -16,7 +16,7 @@ describe('Connector - Passive //', function () { encoding: 'utf8', log: bunyan.createLogger({name: 'passive-test'}), commandSocket: {}, - server: { options: {} } + server: {options: {}} }; let sandbox; diff --git a/test/mochabunyan.opts b/test/mochabunyan.opts deleted file mode 100644 index c664ad12..00000000 --- a/test/mochabunyan.opts +++ /dev/null @@ -1,5 +0,0 @@ -{ - "mute":false, - "level":"fatal", - "reporter":"spec" -} diff --git a/test/start.js b/test/start.js index 1653cd46..e50d50e5 100644 --- a/test/start.js +++ b/test/start.js @@ -19,7 +19,7 @@ const server = new FtpServer('ftp://127.0.0.1:8880', { }); server.on('login', ({username, password}, resolve, reject) => { if (username === 'test' && password === 'test' || username === 'anonymous') { - resolve({ root: require('os').homedir() }); + resolve({root: require('os').homedir()}); } else reject('Bad username or password'); }); server.listen();