aboutsummaryrefslogtreecommitdiff
path: root/test/background/keys.test.js
blob: 2cb9a3a353bf7c84ab6b627272b74ea7e5800e97 (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
import { expect } from "chai";
import * as keys from '../../src/background/keys';

describe("keys", () => {
  const KEYMAP = {
    'g<C-X>GG': [],
    'gg': { type: 'scroll.top' },
  };

  const g = 'g'.charCodeAt(0);
  const G = 'G'.charCodeAt(0);
  const x = 'x'.charCodeAt(0);

  describe('#asKeymapChars', () => {
    let keySequence = [
      { code: g },
      { code: x, ctrl: true },
      { code: G }
    ];
    expect(keys.asKeymapChars(keySequence)).to.equal('g<C-X>G');
  });

  describe('#asCaretChars', () => {
    let keySequence = [
      { code: g },
      { code: x, ctrl: true },
      { code: G }
    ];
    expect(keys.asCaretChars(keySequence)).to.equal('g^XG');
  });
});