aboutsummaryrefslogtreecommitdiff
path: root/test/background/keys.test.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 21:28:00 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 22:14:55 +0900
commit879b5afe66ee79424c3ffee3951ef1c0b8c86eaa (patch)
tree0306dfc26a4312f14084e295deefdf235abad34f /test/background/keys.test.js
parentadc6a5175c0d8b83e45b9e8d99109c1605ad29ac (diff)
key input sequence as action/reducer
Diffstat (limited to 'test/background/keys.test.js')
-rw-r--r--test/background/keys.test.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/background/keys.test.js b/test/background/keys.test.js
new file mode 100644
index 0000000..2cb9a3a
--- /dev/null
+++ b/test/background/keys.test.js
@@ -0,0 +1,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');
+ });
+});