blob: d187e1e8b7bb7e78013cd99dd9ca1e401f60224f (
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
30
|
import CommandLineParser, {
InputPhase,
} from "../../../src/console/commandline/CommandLineParser";
import { Command } from "../../../src/shared/Command";
describe("CommandLineParser", () => {
describe("#inputPhase", () => {
it("returns parsed command-line", () => {
const sut = new CommandLineParser();
expect(sut.inputPhase("")).toEqual(InputPhase.OnCommand);
expect(sut.inputPhase("op")).toEqual(InputPhase.OnCommand);
expect(sut.inputPhase("open ")).toEqual(InputPhase.OnArgs);
expect(sut.inputPhase("open apple")).toEqual(InputPhase.OnArgs);
});
});
describe("#parse", () => {
it("returns parsed command-line", () => {
const sut = new CommandLineParser();
expect(sut.parse("open google apple")).toEqual({
command: Command.Open,
args: "google apple",
});
expect(sut.parse("qa")).toEqual({
command: Command.QuitAll,
args: "",
});
});
});
});
|