aboutsummaryrefslogtreecommitdiff
path: root/test/actions/command.test.js
blob: 01a67f2d7bf97fb2cd3e0eef56febd257a7f8ca5 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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');
      });
    });
  });
});