aboutsummaryrefslogtreecommitdiff
path: root/test/content/components/common
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-11-12 18:25:14 +0900
committerGitHub <noreply@github.com>2017-11-12 18:25:14 +0900
commitc7b05482f33cc778e1966faa9354ea46b490a115 (patch)
treeb73bc6e5a6468d8c5a1118dcfb61f9d00b1aa5cf /test/content/components/common
parent3af2e3154ed6b56400d02fc3d726bfc7186f372a (diff)
parentccf3c7b421e804172827dd34a995290afc85af10 (diff)
Merge pull request #132 from ueokande/meta-keys
Meta keys
Diffstat (limited to 'test/content/components/common')
-rw-r--r--test/content/components/common/input.test.js41
1 files changed, 5 insertions, 36 deletions
diff --git a/test/content/components/common/input.test.js b/test/content/components/common/input.test.js
index 912ac34..a346cf6 100644
--- a/test/content/components/common/input.test.js
+++ b/test/content/components/common/input.test.js
@@ -4,20 +4,21 @@ import { expect } from "chai";
describe('InputComponent', () => {
it('register callbacks', () => {
let component = new InputComponent(window.document);
+ let key = { key: 'a', ctrlKey: true, shiftKey: false, altKey: false, metaKey: false };
component.onKey((key) => {
- expect(key).is.equals('a');
+ expect(key).to.deep.equal(key);
});
- component.onKeyDown({ key: 'a' });
+ component.onKeyDown(key);
});
it('invoke callback once', () => {
let component = new InputComponent(window.document);
let a = 0, b = 0;
component.onKey((key) => {
- if (key == 'a') {
+ if (key.key == 'a') {
++a;
} else {
- key == 'b'
+ key.key == 'b'
++b;
}
});
@@ -32,38 +33,6 @@ describe('InputComponent', () => {
expect(b).is.equals(1);
})
- it('add prefix when ctrl pressed', () => {
- let component = new InputComponent(window.document);
- component.onKey((key) => {
- expect(key).is.equals('<C-A>');
- });
- component.onKeyDown({ key: 'a', ctrlKey: true });
- })
-
- it('press X', () => {
- let component = new InputComponent(window.document);
- component.onKey((key) => {
- expect(key).is.equals('X');
- });
- component.onKeyDown({ key: 'X', shiftKey: true });
- })
-
- it('press <Shift> + <Esc>', () => {
- let component = new InputComponent(window.document);
- component.onKey((key) => {
- expect(key).is.equals('<S-Esc>');
- });
- component.onKeyDown({ key: 'Escape', shiftKey: true });
- })
-
- it('press <Ctrl> + <Esc>', () => {
- let component = new InputComponent(window.document);
- component.onKey((key) => {
- expect(key).is.equals('<C-Esc>');
- });
- component.onKeyDown({ key: 'Escape', ctrlKey: true });
- })
-
it('does not invoke only meta keys', () => {
let component = new InputComponent(window.document);
component.onKey((key) => {