From 99a885cd44f708efa2c2284927ba73507eef7922 Mon Sep 17 00:00:00 2001 From: Tyler Stewart Date: Fri, 7 Jul 2017 17:12:48 -0600 Subject: [PATCH] test(commands): update parser tests --- test/commands/index.spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/commands/index.spec.js b/test/commands/index.spec.js index 8667662..54c4daa 100644 --- a/test/commands/index.spec.js +++ b/test/commands/index.spec.js @@ -53,6 +53,29 @@ describe('FtpCommands', function () { expect(cmd.arg).to.equal('arg1 arg2'); expect(cmd.raw).to.equal('test arg1 arg2'); }); + + it('two args with quotes: test "hello world"', () => { + const cmd = commands.parse('test "hello world"'); + expect(cmd.directive).to.equal('TEST'); + expect(cmd.arg).to.equal('hello world'); + expect(cmd.raw).to.equal('test "hello world"'); + }); + + it('two args, with flags: test -l arg1 -A arg2 --zz88A', () => { + const cmd = commands.parse('test -l arg1 -A arg2 --zz88A'); + expect(cmd.directive).to.equal('TEST'); + expect(cmd.arg).to.equal('arg1 arg2'); + expect(cmd.flags).to.deep.equal(['-l', '-A', '--zz88A']); + expect(cmd.raw).to.equal('test -l arg1 -A arg2 --zz88A'); + }); + + it('one arg, with flags: list -l', () => { + const cmd = commands.parse('list -l'); + expect(cmd.directive).to.equal('LIST'); + expect(cmd.arg).to.equal(null); + expect(cmd.flags).to.deep.equal(['-l']); + expect(cmd.raw).to.equal('list -l'); + }); }); describe('handle', function () {