add command actions test

jh-changes
Shin'ya Ueoka 7 years ago
parent bf890a6d9d
commit 2190a525b4
  1. 2
      src/actions/command.js
  2. 51
      test/actions/command.test.js

@ -22,7 +22,7 @@ export function exec(line) {
case 'tabopen': case 'tabopen':
return { return {
type: actions.COMMAND_TABOPEN_URL, type: actions.COMMAND_TABOPEN_URL,
url: remaining url: normalizeUrl(remaining)
}; };
case 'b': case 'b':
case 'buffer': case 'buffer':

@ -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');
});
});
});
});