From 036ede3379285cbe678d79aad3b9442dca8b31e6 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 5 Nov 2017 09:47:30 +0900 Subject: support mutliple modifiers for key bindings --- test/content/components/common/input.test.js | 41 ++++------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) (limited to 'test/content/components') 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(''); - }); - 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 + ', () => { - let component = new InputComponent(window.document); - component.onKey((key) => { - expect(key).is.equals(''); - }); - component.onKeyDown({ key: 'Escape', shiftKey: true }); - }) - - it('press + ', () => { - let component = new InputComponent(window.document); - component.onKey((key) => { - expect(key).is.equals(''); - }); - component.onKeyDown({ key: 'Escape', ctrlKey: true }); - }) - it('does not invoke only meta keys', () => { let component = new InputComponent(window.document); component.onKey((key) => { -- cgit v1.2.3