diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-03-24 21:53:09 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-03-25 06:41:00 +0900 |
commit | 2e1356b4c67206e1eda82d842fe4280452a048ff (patch) | |
tree | a1a5da44e5bbd0bf6d28e559dbc7fc090a64b571 /test/console/commandline/CommandLineParser.test.ts | |
parent | 348051972ea816e506e483cb363bfea1e1474d23 (diff) |
Add command-line parser on console scripts
Diffstat (limited to 'test/console/commandline/CommandLineParser.test.ts')
-rw-r--r-- | test/console/commandline/CommandLineParser.test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/console/commandline/CommandLineParser.test.ts b/test/console/commandline/CommandLineParser.test.ts new file mode 100644 index 0000000..6aec682 --- /dev/null +++ b/test/console/commandline/CommandLineParser.test.ts @@ -0,0 +1,29 @@ +import CommandLineParser, {InputPhase} from "../../../src/console/commandline/CommandLineParser"; +import { Command } from "../../../src/shared/Command"; +import { expect } from "chai"; + +describe("CommandLineParser", () => { + describe("#inputPhase", () => { + it("returns parsed command-line", () => { + const sut = new CommandLineParser(); + expect(sut.inputPhase("")).to.equal(InputPhase.OnCommand); + expect(sut.inputPhase("op")).to.equal(InputPhase.OnCommand); + expect(sut.inputPhase("open ")).to.equal(InputPhase.OnArgs); + expect(sut.inputPhase("open apple")).to.equal(InputPhase.OnArgs) + }); + }); + describe("#parse", () => { + it("returns parsed command-line", () => { + const sut = new CommandLineParser(); + expect(sut.parse("open google apple")).to.deep.equal({ + command: Command.Open, + args: "google apple", + }); + + expect(sut.parse("qa")).to.deep.equal({ + command: Command.QuitAll, + args: "", + }); + }) + }) +}); |