aboutsummaryrefslogtreecommitdiff
path: root/test/actions
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-11 21:45:48 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-11 21:45:48 +0900
commitb2cddcd69b4ae06770d66808624fc43f3dcbcb0e (patch)
tree548eb65f678cfa1dca36773f01c635ec6c0e2066 /test/actions
parent15d39a479aa7f2c4b804bac8c4352dd0a120bc75 (diff)
parent7bc569eac745b97137e1db8b9271493b3e5c8a20 (diff)
Merge branch 'message-passing-refactoring'
Diffstat (limited to 'test/actions')
-rw-r--r--test/actions/background.test.js14
-rw-r--r--test/actions/command.test.js51
-rw-r--r--test/actions/console.test.js37
-rw-r--r--test/actions/input.test.js21
4 files changed, 123 insertions, 0 deletions
diff --git a/test/actions/background.test.js b/test/actions/background.test.js
new file mode 100644
index 0000000..a3203ee
--- /dev/null
+++ b/test/actions/background.test.js
@@ -0,0 +1,14 @@
+import { expect } from "chai";
+import actions from '../../src/actions';
+import * as backgroundActions from '../../src/actions/background';
+
+describe("background actions", () => {
+ describe("requestCompletions", () => {
+ it('create BACKGROUND_REQUEST_COMPLETIONS action', () => {
+ let action = backgroundActions.requestCompletions('buffer hoge fuga');
+ expect(action.type).to.equal(actions.BACKGROUND_REQUEST_COMPLETIONS);
+ expect(action.command).to.equal('buffer');
+ expect(action.keywords).to.equal('hoge fuga');
+ });
+ });
+});
diff --git a/test/actions/command.test.js b/test/actions/command.test.js
new file mode 100644
index 0000000..01a67f2
--- /dev/null
+++ b/test/actions/command.test.js
@@ -0,0 +1,51 @@
+import { expect } from "chai";
+import actions from '../../src/actions';
+import * as commandActions from '../../src/actions/command';
+
+describe("command actions", () => {
+ describe("exec", () => {
+ context("open command", () => {
+ it('create COMMAND_OPEN_URL acion with a full url', () => {
+ let action = commandActions.exec("open https://github.com/")
+ expect(action.type).to.equal(actions.COMMAND_OPEN_URL);
+ expect(action.url).to.equal('https://github.com/');
+ });
+
+ it('create COMMAND_OPEN_URL acion with a domain name', () => {
+ let action = commandActions.exec("open github.com")
+ expect(action.type).to.equal(actions.COMMAND_OPEN_URL);
+ expect(action.url).to.equal('http://github.com');
+ });
+ });
+
+ context("tabopen command", () => {
+ it('create COMMAND_TABOPEN_URL acion with a full url', () => {
+ let action = commandActions.exec("tabopen https://github.com/")
+ expect(action.type).to.equal(actions.COMMAND_TABOPEN_URL);
+ expect(action.url).to.equal('https://github.com/');
+ });
+
+ it('create COMMAND_TABOPEN_URL acion with a domain name', () => {
+ let action = commandActions.exec("tabopen github.com")
+ expect(action.type).to.equal(actions.COMMAND_TABOPEN_URL);
+ expect(action.url).to.equal('http://github.com');
+ });
+ });
+
+ context("buffer command", () => {
+ it('create COMMAND_BUFFER acion with a keywords', () => {
+ let action = commandActions.exec("buffer foo bar")
+ expect(action.type).to.equal(actions.COMMAND_BUFFER);
+ expect(action.keywords).to.equal('foo bar');
+ });
+ });
+
+ context("b command", () => {
+ it('create COMMAND_BUFFER acion with a keywords', () => {
+ let action = commandActions.exec("b foo bar")
+ expect(action.type).to.equal(actions.COMMAND_BUFFER);
+ expect(action.keywords).to.equal('foo bar');
+ });
+ });
+ });
+});
diff --git a/test/actions/console.test.js b/test/actions/console.test.js
new file mode 100644
index 0000000..512ee40
--- /dev/null
+++ b/test/actions/console.test.js
@@ -0,0 +1,37 @@
+import { expect } from "chai";
+import actions from '../../src/actions';
+import * as consoleActions from '../../src/actions/console';
+
+describe("console actions", () => {
+ describe("showCommand", () => {
+ it('create CONSOLE_SHOW_COMMAND action', () => {
+ let action = consoleActions.showCommand('hello');
+ expect(action.type).to.equal(actions.CONSOLE_SHOW_COMMAND);
+ expect(action.text).to.equal('hello');
+ });
+ });
+
+ describe("setCompletions", () => {
+ it('create CONSOLE_SET_COMPLETIONS action', () => {
+ let action = consoleActions.setCompletions([1,2,3]);
+ expect(action.type).to.equal(actions.CONSOLE_SET_COMPLETIONS);
+ expect(action.completions).to.deep.equal([1, 2, 3]);
+ });
+ });
+
+ describe("showError", () => {
+ it('create CONSOLE_SHOW_ERROR action', () => {
+ let action = consoleActions.showError('an error');
+ expect(action.type).to.equal(actions.CONSOLE_SHOW_ERROR);
+ expect(action.text).to.equal('an error');
+ });
+ });
+
+ describe("hide", () => {
+ it('create CONSOLE_HIDE action', () => {
+ let action = consoleActions.hide();
+ expect(action.type).to.equal(actions.CONSOLE_HIDE);
+ });
+ });
+});
+
diff --git a/test/actions/input.test.js b/test/actions/input.test.js
new file mode 100644
index 0000000..9ec6de4
--- /dev/null
+++ b/test/actions/input.test.js
@@ -0,0 +1,21 @@
+import { expect } from "chai";
+import actions from '../../src/actions';
+import * as inputActions from '../../src/actions/input';
+
+describe("input actions", () => {
+ describe("keyPress", () => {
+ it('create INPUT_KEY_PRESS action', () => {
+ let action = inputActions.keyPress(123, true);
+ expect(action.type).to.equal(actions.INPUT_KEY_PRESS);
+ expect(action.code).to.equal(123);
+ expect(action.ctrl).to.be.true;
+ });
+ });
+
+ describe("clearKeys", () => {
+ it('create INPUT_CLEAR_KEYSaction', () => {
+ let action = inputActions.clearKeys();
+ expect(action.type).to.equal(actions.INPUT_CLEAR_KEYS);
+ });
+ });
+});