aboutsummaryrefslogtreecommitdiff
path: root/test/console/commandline/CommandParser.test.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-03-24 21:53:09 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2020-03-25 06:41:00 +0900
commit2e1356b4c67206e1eda82d842fe4280452a048ff (patch)
treea1a5da44e5bbd0bf6d28e559dbc7fc090a64b571 /test/console/commandline/CommandParser.test.ts
parent348051972ea816e506e483cb363bfea1e1474d23 (diff)
Add command-line parser on console scripts
Diffstat (limited to 'test/console/commandline/CommandParser.test.ts')
-rw-r--r--test/console/commandline/CommandParser.test.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/console/commandline/CommandParser.test.ts b/test/console/commandline/CommandParser.test.ts
new file mode 100644
index 0000000..4ad78fd
--- /dev/null
+++ b/test/console/commandline/CommandParser.test.ts
@@ -0,0 +1,15 @@
+import CommandParser, { UnknownCommandError } from "../../../src/console/commandline/CommandParser";
+import { Command } from "../../../src/shared/Command";
+import { expect } from "chai"
+
+describe("CommandParser", () => {
+ describe("#parse", () => {
+ it("returns matched command with the string", () => {
+ const sut = new CommandParser();
+ expect(sut.parse("open")).to.equal(Command.Open);
+ expect(sut.parse("w")).to.equal(Command.WindowOpen);
+ expect(sut.parse("bdelete!")).to.equal(Command.BufferDeleteForce);
+ expect(() => sut.parse("harakiri")).to.throw(UnknownCommandError);
+ })
+ })
+});