From b4b9d835693b2c557deeedc599d31e76ceecac88 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Tue, 20 Oct 2020 21:09:49 -0400 Subject: [PATCH] Adjust tests, fix typo --- src/lib/services/PhysicalKeyboard.js | 4 +-- .../services/tests/PhysicalKeyboard.test.js | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/lib/services/PhysicalKeyboard.js b/src/lib/services/PhysicalKeyboard.js index 40774173..75c9adc7 100644 --- a/src/lib/services/PhysicalKeyboard.js +++ b/src/lib/services/PhysicalKeyboard.js @@ -37,7 +37,7 @@ class PhysicalKeyboard { if (options.physicalKeyboardHighlightPress) { /** - * Trigger mousedown + * Trigger pointerdown */ ( buttonDOM.onpointerdown || @@ -64,7 +64,7 @@ class PhysicalKeyboard { if (options.physicalKeyboardHighlightPress) { /** - * Trigger mousedown + * Trigger pointerup */ ( buttonDOM.onpointerup || diff --git a/src/lib/services/tests/PhysicalKeyboard.test.js b/src/lib/services/tests/PhysicalKeyboard.test.js index 51edad3c..68199e06 100644 --- a/src/lib/services/tests/PhysicalKeyboard.test.js +++ b/src/lib/services/tests/PhysicalKeyboard.test.js @@ -159,6 +159,41 @@ it('PhysicalKeyboard will work with physicalKeyboardHighlightPress (touch)', () } })); + document.dispatchEvent(new KeyboardEvent('keyup', { + code: "KeyF", + key: "f", + target: { + tagName: "input" + } + })); +}); + +it('PhysicalKeyboard with physicalKeyboardHighlightPress can trigger noop', () => { + setDOM(); + + const keyboard = new Keyboard({ + physicalKeyboardHighlight: true, + physicalKeyboardHighlightPress: true, + useTouchEvents: true, + debug: true + }); + + keyboard.getButtonElement('f').onmousedown = null; + keyboard.getButtonElement('f').onpointerdown = null; + keyboard.getButtonElement('f').ontouchstart = null; + + document.dispatchEvent(new KeyboardEvent('keydown', { + code: "KeyF", + key: "f", + target: { + tagName: "input" + } + })); + + keyboard.getButtonElement('f').onmouseup = null; + keyboard.getButtonElement('f').onpointerup = null; + keyboard.getButtonElement('f').ontouchend = null; + document.dispatchEvent(new KeyboardEvent('keyup', { code: "KeyF", key: "f",