From c59f819db91e76fad0cbf28c0efbbb8807416fb2 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Thu, 17 Jan 2019 18:36:19 -0500 Subject: [PATCH] Tests update --- src/lib/components/tests/Keyboard.test.js | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/lib/components/tests/Keyboard.test.js b/src/lib/components/tests/Keyboard.test.js index a8ecc43b..33c2e933 100644 --- a/src/lib/components/tests/Keyboard.test.js +++ b/src/lib/components/tests/Keyboard.test.js @@ -598,6 +598,42 @@ it('Keyboard caretEventHandler will detect input, textarea focus', () => { expect(keyboard.caretPosition).toBe(3); }); +it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositioning', () => { + testUtil.setDOM(); + + let keyboard = new Keyboard(); + + keyboard.caretEventHandler({ + charCode: 0, + code: "KeyF", + key: "f", + which: 70, + target: { + tagName: "input", + selectionStart: 3 + } + }); + + expect(keyboard.caretPosition).toBe(3); + + keyboard.setOptions({ + disableCaretPositioning: true + }); + + keyboard.caretEventHandler({ + charCode: 0, + code: "KeyF", + key: "f", + which: 70, + target: { + tagName: "input", + selectionStart: 3 + } + }); + + expect(keyboard.caretPosition).toBeFalsy(); +}); + it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', () => { testUtil.setDOM();