aboutsummaryrefslogtreecommitdiff
path: root/test/console
diff options
context:
space:
mode:
Diffstat (limited to 'test/console')
-rw-r--r--test/console/actions/console.test.ts9
-rw-r--r--test/console/commandline/CommandLineParser.test.ts29
-rw-r--r--test/console/commandline/CommandParser.test.ts15
3 files changed, 49 insertions, 4 deletions
diff --git a/test/console/actions/console.test.ts b/test/console/actions/console.test.ts
index 583c878..e6567b2 100644
--- a/test/console/actions/console.test.ts
+++ b/test/console/actions/console.test.ts
@@ -1,5 +1,6 @@
-import * as actions from 'console/actions';
-import * as consoleActions from 'console/actions/console';
+import * as actions from '../../../src/console/actions';
+import * as consoleActions from '../../../src/console/actions/console';
+import { expect } from 'chai';
describe("console actions", () => {
describe('hide', () => {
@@ -9,8 +10,8 @@ describe("console actions", () => {
});
});
describe("showCommand", () => {
- it('create CONSOLE_SHOW_COMMAND action', () => {
- const action = consoleActions.showCommand('hello');
+ it('create CONSOLE_SHOW_COMMAND action', async () => {
+ const action = await consoleActions.showCommand('hello');
expect(action.type).to.equal(actions.CONSOLE_SHOW_COMMAND);
expect(action.text).to.equal('hello');
});
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: "",
+ });
+ })
+ })
+});
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);
+ })
+ })
+});