Files
ftp-server/test/commands/mode.spec.js
Tyler Stewart 795c3d7c65 refactor(commands): commands now store all info about themselves
Makes it easier to modify a command

Each command exports an object:
{
  directive: string or array of commands that call this handler
  handler: function to process the command
  syntax: string of how to call the command
  description: human readable explaination of command
  flags: optional object of flags
}
2017-03-08 12:31:44 -07:00

40 lines
865 B
JavaScript

const when = require('when');
const {expect} = require('chai');
const sinon = require('sinon')
const CMD = 'MODE';
describe(CMD, done => {
let sandbox;
const mockClient = {
reply: () => when.resolve()
};
const CMDFN = require(`../../src/commands/registration/${CMD.toLowerCase()}`).handler.bind(mockClient);
beforeEach(() => {
sandbox = sinon.sandbox.create();
sandbox.spy(mockClient, 'reply');
});
afterEach(() => {
sandbox.restore();
});
it('S // successful', done => {
CMDFN({command: {_: [CMD, 'S']}})
.then(() => {
expect(mockClient.reply.args[0][0]).to.equal(200)
done();
})
.catch(done);
});
it('Q // unsuccessful', done => {
CMDFN({command: {_: [CMD, 'Q']}})
.then(() => {
expect(mockClient.reply.args[0][0]).to.equal(504)
done();
})
.catch(done);
});
});