aboutsummaryrefslogtreecommitdiff
path: root/test/console/commandline/CommandLineParser.test.ts
blob: 6aec6821dd8a42057b3d20b7c17ec02446695765 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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: "",
      });
    })
  })
});