aboutsummaryrefslogtreecommitdiff
path: root/test/console/commandline/CommandParser.test.ts
blob: f72afd686612c54cc906d8d69ce753b2558e4d46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
    });
  });
});