Linting codebase

This commit is contained in:
Francisco Hodge 2020-02-06 00:26:22 -05:00
parent 7fd757cd02
commit 304f47701e
13 changed files with 228 additions and 240 deletions

View File

@ -43,8 +43,8 @@ class Demo {
}
handleShift() {
let currentLayout = this.keyboard.options.layoutName;
let shiftToggle = currentLayout === "default" ? "shift" : "default";
const currentLayout = this.keyboard.options.layoutName;
const shiftToggle = currentLayout === "default" ? "shift" : "default";
this.keyboard.setOptions({
layoutName: shiftToggle

View File

@ -61,8 +61,8 @@ class Demo {
}
handleShift() {
let currentLayout = this.keyboard.options.layoutName;
let shiftToggle = currentLayout === "default" ? "shift" : "default";
const currentLayout = this.keyboard.options.layoutName;
const shiftToggle = currentLayout === "default" ? "shift" : "default";
this.keyboard.setOptions({
layoutName: shiftToggle

View File

@ -27,7 +27,7 @@ class Demo {
/**
* Demo Start
*/
let commonKeyboardOptions = {
const commonKeyboardOptions = {
onChange: input => this.onChange(input),
onKeyPress: button => this.onKeyPress(button),
theme: "simple-keyboard hg-theme-default hg-layout-default",
@ -116,8 +116,8 @@ class Demo {
}
});
document.querySelector(".input").addEventListener("input", event => {
let input = document.querySelector(".input").value;
document.querySelector(".input").addEventListener("input", () => {
const input = document.querySelector(".input").value;
this.keyboard.setInput(input);
});
}
@ -145,8 +145,8 @@ class Demo {
}
handleShift() {
let currentLayout = this.keyboard.options.layoutName;
let shiftToggle = currentLayout === "default" ? "shift" : "default";
const currentLayout = this.keyboard.options.layoutName;
const shiftToggle = currentLayout === "default" ? "shift" : "default";
this.keyboard.setOptions({
layoutName: shiftToggle

View File

@ -76,9 +76,9 @@ class Demo {
}
handleShift(keyboardInstanceKey) {
let keyboard = this[keyboardInstanceKey || "keyboard"];
let currentLayout = keyboard.options.layoutName;
let shiftToggle = currentLayout === "default" ? "shift" : "default";
const keyboard = this[keyboardInstanceKey || "keyboard"];
const currentLayout = keyboard.options.layoutName;
const shiftToggle = currentLayout === "default" ? "shift" : "default";
keyboard.setOptions({
layoutName: shiftToggle

View File

@ -1,18 +1,18 @@
import TestUtility from '../../utils/TestUtility';
import BasicDemo from '../BasicDemo';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Demo will load', () => {
testUtil.setDOM();
let demo = new BasicDemo();
new BasicDemo();
});
it('Demo onDOMLoaded will work', () => {
testUtil.setDOM();
let demo = new BasicDemo();
const demo = new BasicDemo();
expect(demo.keyboard).toBeTruthy();
});
@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new BasicDemo();
const demo = new BasicDemo();
demo.onChange("test");
@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new BasicDemo();
const demo = new BasicDemo();
demo.keyboard.getButtonElement("q").onclick();
@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
it('Demo input change will work', () => {
testUtil.setDOM();
let demo = new BasicDemo();
const demo = new BasicDemo();
document.body.querySelector('.input').value = "test";
document.body.querySelector('.input').dispatchEvent(new Event('input'));
@ -51,7 +51,7 @@ it('Demo input change will work', () => {
it('Demo handleShiftButton will work', () => {
testUtil.setDOM();
let demo = new BasicDemo();
const demo = new BasicDemo();
demo.keyboard.getButtonElement("{shift}")[0].onclick();
expect(demo.keyboard.options.layoutName).toBe("shift");

View File

@ -1,18 +1,18 @@
import TestUtility from '../../utils/TestUtility';
import ButtonThemeDemo from '../ButtonThemeDemo';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Demo will load', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
new ButtonThemeDemo();
});
it('Demo onDOMLoaded will work', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
expect(demo.keyboard).toBeTruthy();
});
@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
demo.onChange("test");
@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
demo.keyboard.getButtonElement("q").onclick();
@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
it('Demo input change will work', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
document.body.querySelector('.input').value = "test";
document.body.querySelector('.input').dispatchEvent(new Event('input'));
@ -51,7 +51,7 @@ it('Demo input change will work', () => {
it('Demo handleShiftButton will work', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
demo.keyboard.getButtonElement("{shift}")[0].onclick();
expect(demo.keyboard.options.layoutName).toBe("shift");
@ -63,15 +63,15 @@ it('Demo handleShiftButton will work', () => {
it('Demo buttons will have proper attributes and classes', () => {
testUtil.setDOM();
let demo = new ButtonThemeDemo();
const demo = new ButtonThemeDemo();
let buttonDOM = demo.keyboard.getButtonElement("b");
const buttonDOM = demo.keyboard.getButtonElement("b");
console.log("buttonDOM", buttonDOM.outerHTML);
let hasAttribute = buttonDOM.hasAttribute("aria-label");
const hasAttribute = buttonDOM.hasAttribute("aria-label");
expect(hasAttribute).toBeTruthy();
let hasClass = buttonDOM.classList.contains("my-button-outline");
const hasClass = buttonDOM.classList.contains("my-button-outline");
expect(hasClass).toBeTruthy();
});

View File

@ -1,18 +1,17 @@
import TestUtility from '../../utils/TestUtility';
import FullKeyboardDemo from '../FullKeyboardDemo';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Demo will load', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
new FullKeyboardDemo();
});
it('Demo onDOMLoaded will work', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
const demo = new FullKeyboardDemo();
expect(demo.keyboard).toBeTruthy();
});
@ -20,7 +19,7 @@ it('Demo onDOMLoaded will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
const demo = new FullKeyboardDemo();
demo.onChange("test");
@ -30,7 +29,7 @@ it('Demo onChange will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
const demo = new FullKeyboardDemo();
demo.keyboard.getButtonElement("q").onclick();
@ -40,7 +39,7 @@ it('Demo onChange will work', () => {
it('Demo input change will work', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
const demo = new FullKeyboardDemo();
document.body.querySelector('.input').value = "test";
document.body.querySelector('.input').dispatchEvent(new Event('input'));
@ -52,7 +51,7 @@ it('Demo input change will work', () => {
it('Demo handleShiftButton will work', () => {
testUtil.setDOM();
let demo = new FullKeyboardDemo();
const demo = new FullKeyboardDemo();
demo.keyboard.getButtonElement("{shiftleft}").onclick();
expect(demo.keyboard.options.layoutName).toBe("shift");

View File

@ -3,18 +3,18 @@ import MultipleKeyboardsDestroyDemo from '../MultipleKeyboardsDestroyDemo';
jest.useFakeTimers();
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Demo will load', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
new MultipleKeyboardsDestroyDemo();
});
it('Demo onDOMLoaded will work', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
expect(demo.keyboard).toBeTruthy();
});
@ -22,7 +22,7 @@ it('Demo onDOMLoaded will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
demo.onChange("test");
demo.keyboard2.getButtonElement("q").click();
@ -34,7 +34,7 @@ it('Demo onChange will work', () => {
it('Demo onChange will work', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
demo.keyboard.getButtonElement("q").onclick();
@ -44,7 +44,7 @@ it('Demo onChange will work', () => {
it('Demo input change will work', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
document.body.querySelector('.input').value = "test";
document.body.querySelector('.input').dispatchEvent(new Event('input'));
@ -59,7 +59,7 @@ it('Demo input change will work', () => {
it('Demo handleShiftButton will work', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
demo.keyboard.getButtonElement("{shift}")[0].onclick();
expect(demo.keyboard.options.layoutName).toBe("shift");
@ -71,7 +71,7 @@ it('Demo handleShiftButton will work', () => {
it('MultipleKeyboardsDestroyDemo will run all timers', () => {
testUtil.setDOM();
let demo = new MultipleKeyboardsDestroyDemo();
const demo = new MultipleKeyboardsDestroyDemo();
jest.runAllTimers();
expect(demo.keyboard.options.theme).toBe("hg-theme-default myTheme");

View File

@ -1,7 +1,7 @@
import Keyboard from '../Keyboard';
import TestUtility from '../../../utils/TestUtility';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Keyboard will not render without target element', () => {
try {
@ -38,7 +38,7 @@ it('Keyboard will run with custom DOM target', () => {
it('Keyboard will run with debug option set', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
@ -51,10 +51,10 @@ it('Keyboard will use touch events', () => {
testUtil.clear()
document.body.innerHTML = `
<div id="keyboard"></div>
<div class="keyboard"></div>
`;
const keyboard = new Keyboard('#keyboard', {
const keyboard = new Keyboard('.keyboard', {
useTouchEvents: true,
onChange: () => touched = true,
layout: {
@ -73,7 +73,7 @@ it('Keyboard will use touch events', () => {
it('Keyboard standard buttons will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: {
"default": 10
}
@ -85,7 +85,7 @@ it('Keyboard standard buttons will work', () => {
it('Keyboard shift buttons will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.setOptions({
layoutName: "shift",
@ -97,7 +97,7 @@ it('Keyboard shift buttons will work', () => {
it('Keyboard setOptions will work without a param', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.setOptions();
});
@ -105,7 +105,7 @@ it('Keyboard setOptions will work without a param', () => {
it('Keyboard empty buttons wont do anything as expected', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
layout: {
default: [
"{//} {button} d",
@ -122,7 +122,7 @@ it('Keyboard onKeyPress will work', () => {
let pressed = false;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
onKeyPress: () => {
pressed = true;
},
@ -137,7 +137,7 @@ it('Keyboard onKeyPress will work', () => {
it('Keyboard standard function buttons will not change input', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
useButtonTag: true
});
@ -158,7 +158,7 @@ it('Keyboard syncInstanceInputs will work', () => {
<div class="keyboard2"></div>
`;
let sharedOptions = {
const sharedOptions = {
syncInstanceInputs: true
};
@ -195,7 +195,7 @@ it('Keyboard onChange will work', () => {
let output = false;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
onChange: (input) => {
output = input;
},
@ -212,7 +212,7 @@ it('Keyboard onChangeAll will work', () => {
let output;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
onChangeAll: (input) => {
output = input ? input.default : null;
},
@ -227,7 +227,7 @@ it('Keyboard onChangeAll will work', () => {
it('Keyboard clearInput will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
/**
* Avoid setInput for this test
@ -249,12 +249,12 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
<div class="keyboard2"></div>
`;
let sharedOptions = {
const sharedOptions = {
syncInstanceInputs: true
};
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
/**
* Avoid setInput for this test
@ -271,7 +271,7 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
it('Keyboard setInput will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.setInput("hello");
@ -286,12 +286,12 @@ it('Keyboard setInput will work with syncInstanceInputs', () => {
<div class="keyboard2"></div>
`;
let sharedOptions = {
const sharedOptions = {
syncInstanceInputs: true
};
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
keyboard1.setInput("hello");
@ -306,8 +306,8 @@ it('Keyboard dispatch will work', () => {
<div class="keyboard2"></div>
`;
let keyboard1 = new Keyboard(".keyboard1");
let keyboard2 = new Keyboard(".keyboard2");
const keyboard1 = new Keyboard(".keyboard1");
const keyboard2 = new Keyboard(".keyboard2");
keyboard1.dispatch(instance => {
instance.setOptions({
@ -331,8 +331,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
<div class="keyboard2"></div>
`;
let keyboard1 = new Keyboard(".keyboard1");
let keyboard2 = new Keyboard(".keyboard2");
const keyboard1 = new Keyboard(".keyboard1");
new Keyboard(".keyboard2");
window['SimpleKeyboardInstances'] = null;
@ -357,8 +357,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
it('Keyboard addButtonTheme will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
let returnVal = keyboard.addButtonTheme("q", "test");
const keyboard = new Keyboard();
keyboard.addButtonTheme("q", "test");
expect(keyboard.options.buttonTheme[0].class).toBe("test");
});
@ -366,8 +366,8 @@ it('Keyboard addButtonTheme will work', () => {
it('Keyboard addButtonTheme will not work without params', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
let returnVal = keyboard.addButtonTheme();
const keyboard = new Keyboard();
const returnVal = keyboard.addButtonTheme();
expect(returnVal).toBeFalsy();
});
@ -375,7 +375,7 @@ it('Keyboard addButtonTheme will not work without params', () => {
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -392,7 +392,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
it('Keyboard addButtonTheme will create a buttonTheme', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "blurb",
@ -409,7 +409,7 @@ it('Keyboard addButtonTheme will create a buttonTheme', () => {
it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -426,7 +426,7 @@ it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -444,7 +444,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
it('Keyboard removeButtonTheme without params will remove all button themes', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -462,7 +462,7 @@ it('Keyboard removeButtonTheme without params will remove all button themes', ()
it('Keyboard removeButtonTheme will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -479,7 +479,7 @@ it('Keyboard removeButtonTheme will work', () => {
it('Keyboard removeButtonTheme will work wihtout a class', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -496,7 +496,7 @@ it('Keyboard removeButtonTheme will work wihtout a class', () => {
it('Keyboard removeButtonTheme will do nothing without a button param', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -513,7 +513,7 @@ it('Keyboard removeButtonTheme will do nothing without a button param', () => {
it('Keyboard removeButtonTheme does nothing if req button doesnt have a buttonTheme', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -530,7 +530,7 @@ it('Keyboard removeButtonTheme does nothing if req button doesnt have a buttonTh
it('Keyboard removeButtonTheme does nothing if buttonTheme class does not exist', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "testy",
@ -547,7 +547,7 @@ it('Keyboard removeButtonTheme does nothing if buttonTheme class does not exist'
it('Keyboard removeButtonTheme does nothing if buttonTheme doesnt have the requested buttons', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
buttonTheme: [
{
class: "test",
@ -564,7 +564,7 @@ it('Keyboard removeButtonTheme does nothing if buttonTheme doesnt have the reque
it('Keyboard getButtonElement will not return anything if empty match', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
layout: {
default: [
"{//} {button} d",
@ -579,7 +579,7 @@ it('Keyboard getButtonElement will not return anything if empty match', () => {
it('Keyboard getButtonElement will return multiple matched buttons', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
expect(keyboard.getButtonElement("{shift}").length).toBe(2);
});
@ -606,7 +606,7 @@ it('Keyboard will receive physical keyboard events', () => {
it('Keyboard caretEventHandler will detect input, textarea focus', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretEventHandler({
charCode: 0,
@ -625,7 +625,7 @@ it('Keyboard caretEventHandler will detect input, textarea focus', () => {
it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositioning', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretEventHandler({
charCode: 0,
@ -661,7 +661,7 @@ it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositio
it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.isMouseHold = true;
@ -682,7 +682,7 @@ it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', (
it('Keyboard caretEventHandler will work with debug', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
@ -705,7 +705,7 @@ it('Keyboard onInit will work', () => {
let passed = false;
let keyboard = new Keyboard({
new Keyboard({
onInit: () => {
passed = true
}
@ -719,7 +719,7 @@ it('Keyboard onRender will work', () => {
let passed = false;
let keyboard = new Keyboard({
new Keyboard({
onRender: () => {
passed = true
}
@ -731,7 +731,7 @@ it('Keyboard onRender will work', () => {
it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
buttonTheme: [
{
class: null,
@ -744,7 +744,7 @@ it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
it('Keyboard buttonTheme buttons that are invalid will be ignored and not throw', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
buttonTheme: [
{
class: null,
@ -772,7 +772,7 @@ it('Keyboard buttonTheme will be ignored if buttons param not a string', () => {
it('Keyboard buttonTheme will be ignored if already added', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
buttonTheme: [
{
class: "test",
@ -801,7 +801,7 @@ it('Keyboard buttonTheme will be ignored if already added', () => {
it('Keyboard can set a module', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.registerModule(
"test",
@ -816,7 +816,7 @@ it('Keyboard can set a module', () => {
it('Keyboard registerModule will return current module tree', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.modules.test = {
testy: "test"
@ -836,7 +836,7 @@ it('Keyboard registerModule will return current module tree', () => {
it('Keyboard can set a module by amending the modules tree', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.modules = {
testman: {
@ -857,7 +857,7 @@ it('Keyboard can set a module by amending the modules tree', () => {
it('Keyboard will not retrieve an option for an inexistent module', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
expect(keyboard.getModuleProp("test", "foo")).toBeFalsy();
});
@ -865,7 +865,7 @@ it('Keyboard will not retrieve an option for an inexistent module', () => {
it('Keyboard will get a list of modules', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.registerModule(
"test",
@ -886,7 +886,7 @@ it('Keyboard loadModules will load a simple module', () => {
};
}
let keyboard = new Keyboard({
new Keyboard({
modules: [
myClass
]
@ -896,7 +896,7 @@ it('Keyboard loadModules will load a simple module', () => {
it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.isMouseHold = true;
@ -908,7 +908,7 @@ it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.isMouseHold = true;
keyboard.holdInteractionTimeout = setTimeout(() => {}, 10000);
@ -919,7 +919,7 @@ it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
it('Keyboard handleButtonMouseDown will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.handleButtonMouseDown("q", {
target: keyboard.getButtonElement("q"),
@ -937,7 +937,7 @@ it('Keyboard handleButtonMouseDown will work', () => {
it('Keyboard handleButtonMouseDown will work with preventMouseDownDefault', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.options.preventMouseDownDefault = true;
@ -965,7 +965,7 @@ it('Keyboard onModulesLoaded will work', () => {
let foo;
let keyboard = new Keyboard({
new Keyboard({
modules: [
myClass
],
@ -980,7 +980,7 @@ it('Keyboard onModulesLoaded will work', () => {
it('Keyboard inputPattern will work globally', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
inputPattern: /^\d+$/,
useMouseEvents: true
});
@ -997,7 +997,7 @@ it('Keyboard inputPattern will work globally', () => {
it('Keyboard inputPattern will work by input name', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true,
inputName: "test1",
inputPattern: {
@ -1026,7 +1026,7 @@ it('Keyboard processAutoTouchEvents will work', () => {
navigator.maxTouchPoints = true;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
autoUseTouchEvents: true
});
@ -1038,7 +1038,7 @@ it('Keyboard processAutoTouchEvents will work with debugging enabled', () => {
navigator.maxTouchPoints = true;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
autoUseTouchEvents: true,
debug: true
});
@ -1051,7 +1051,7 @@ it('Keyboard beforeFirstRender method will work', () => {
let timesCalled = 0;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
beforeFirstRender: () => {
timesCalled++;
}
@ -1074,7 +1074,7 @@ it('Keyboard beforeFirstRender will show PointerEvents warning', () => {
window.PointerEvent = window.PointerEvent ? window.PointerEvent : () => {};
let keyboard = new Keyboard({
new Keyboard({
debug: true,
beforeFirstRender: () => {
timesCalled++;
@ -1089,7 +1089,7 @@ it('Keyboard beforeRender method will work', () => {
let timesCalled = 0;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
beforeRender: () => {
timesCalled++;
}
@ -1108,7 +1108,7 @@ it('Keyboard beforeRender method will work', () => {
it('Keyboard parseRowDOMContainers will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
layout: {
'default': [
'` [1 2 3 4 5 6 7 8 9] 0 - = {bksp}',
@ -1127,7 +1127,7 @@ it('Keyboard parseRowDOMContainers will work', () => {
}
});
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
expect(containers.length).toBe(5);
@ -1144,7 +1144,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
let failed = false;
try {
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.parseRowDOMContainers({
children: []
});
@ -1159,7 +1159,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex before startIndex', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
layout: {
'default': [
'` [1 2 3 4 5 6 7 8 9 0 - = {bksp}',
@ -1168,7 +1168,7 @@ it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex befo
}
});
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
expect(containers.length).toBe(0);
});
@ -1176,7 +1176,7 @@ it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex befo
it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
disableRowButtonContainers: true,
layout: {
'default': [
@ -1196,7 +1196,7 @@ it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () =
}
});
let containers = Array.from(document.querySelectorAll(".hg-button-container"));
const containers = Array.from(document.querySelectorAll(".hg-button-container"));
expect(containers.length).toBe(0);
});
@ -1204,7 +1204,7 @@ it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () =
it('Keyboard inputName change will trigget caretPosition reset', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretPosition = 0;
@ -1227,7 +1227,7 @@ it('Keyboard inputName change will trigget caretPosition reset', () => {
it('Keyboard destroy will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.destroy();
expect(keyboard.keyboardDOM.innerHTML).toBe("");
});
@ -1235,7 +1235,7 @@ it('Keyboard destroy will work', () => {
it('Keyboard destroy will work with debug option', () => {
testUtil.setDOM();
let keyboard = new Keyboard({ debug: true });
const keyboard = new Keyboard({ debug: true });
keyboard.destroy();
expect(keyboard.keyboardDOM.innerHTML).toBe("");
});
@ -1243,7 +1243,7 @@ it('Keyboard destroy will work with debug option', () => {
it('Keyboard disableButtonHold will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
disableButtonHold: true
});
@ -1253,7 +1253,7 @@ it('Keyboard disableButtonHold will work', () => {
it('Keyboard caretEventHandler will be triggered on mouseup and ontouchend', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
disableCaretPositioning: true
});
@ -1289,7 +1289,7 @@ it('Keyboard onKeyReleased will work', () => {
let firedTimes = 0;
let buttonPressed;
let keyboard = new Keyboard({
const keyboard = new Keyboard({
onKeyReleased: button => {
pressed = true;
buttonPressed = button;
@ -1309,7 +1309,7 @@ it('Keyboard onKeyReleased will work', () => {
it('Keyboard buttonAttribute will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
buttonAttributes: [
{
attribute: "aria-label",
@ -1323,7 +1323,7 @@ it('Keyboard buttonAttribute will work', () => {
it('Keyboard buttonAttribute will warn about invalid entries', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
buttonAttributes: [
{
attribute: false,
@ -1335,6 +1335,6 @@ it('Keyboard buttonAttribute will warn about invalid entries', () => {
it('Keyboard recurseButtons will not work without a valid param', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
expect(keyboard.recurseButtons()).toBe(false);
});

View File

@ -1,29 +1,18 @@
/**
* Keyboard Layout Service
*/
class KeyboardLayout {
/**
* Get default simple-keyboard layout
* @return {object} The default layout (US-QWERTY)
*/
static getDefaultLayout() {
return {
default: [
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
"{tab} q w e r t y u i o p [ ] \\",
"{lock} a s d f g h j k l ; ' {enter}",
"{shift} z x c v b n m , . / {shift}",
".com @ {space}"
],
shift: [
"~ ! @ # $ % ^ & * ( ) _ + {bksp}",
"{tab} Q W E R T Y U I O P { } |",
'{lock} A S D F G H J K L : " {enter}',
"{shift} Z X C V B N M < > ? {shift}",
".com @ {space}"
]
};
}
}
export default KeyboardLayout;
export const getDefaultLayout = () => {
return {
default: [
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
"{tab} q w e r t y u i o p [ ] \\",
"{lock} a s d f g h j k l ; ' {enter}",
"{shift} z x c v b n m , . / {shift}",
".com @ {space}"
],
shift: [
"~ ! @ # $ % ^ & * ( ) _ + {bksp}",
"{tab} Q W E R T Y U I O P { } |",
'{lock} A S D F G H J K L : " {enter}',
"{shift} Z X C V B N M < > ? {shift}",
".com @ {space}"
]
};
};

View File

@ -21,11 +21,11 @@ class PhysicalKeyboard {
}
handleHighlightKeyDown(event) {
let options = this.getOptions();
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
const options = this.getOptions();
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
this.dispatch(instance => {
let buttonDOM =
const buttonDOM =
instance.getButtonElement(buttonPressed) ||
instance.getButtonElement(`{${buttonPressed}}`);
@ -39,10 +39,10 @@ class PhysicalKeyboard {
}
handleHighlightKeyUp(event) {
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
this.dispatch(instance => {
let buttonDOM =
const buttonDOM =
instance.getButtonElement(buttonPressed) ||
instance.getButtonElement(`{${buttonPressed}}`);

View File

@ -1,12 +1,12 @@
import Keyboard from '../../components/Keyboard';
import TestUtility from '../../../utils/TestUtility';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true
});
@ -22,7 +22,7 @@ it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', ()
it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: false
});
@ -38,7 +38,7 @@ it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight',
it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true
});
@ -54,7 +54,7 @@ it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true
});
@ -70,7 +70,7 @@ it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () =
it('PhysicalKeyboard keyup will be handle special buttons', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true
});
@ -86,7 +86,7 @@ it('PhysicalKeyboard keyup will be handle special buttons', () => {
it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true,
debug: true
});
@ -103,7 +103,7 @@ it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
it('PhysicalKeyboard will work with F1-F12 keys', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
new Keyboard({
physicalKeyboardHighlight: true,
debug: true
});

View File

@ -1,12 +1,12 @@
import Keyboard from '../../components/Keyboard';
import TestUtility from '../../../utils/TestUtility';
let testUtil = new TestUtility();
const testUtil = new TestUtility();
it('Keyboard mergeDisplay will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
mergeDisplay: true,
display: {
"q": "qreplaced"
@ -29,9 +29,9 @@ it('Keyboard function buttons will work', () => {
it('Keyboard {bksp} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{bksp}", "test");
const output = keyboard.utilities.getUpdatedInput("{bksp}", "test");
expect(output).toBe("tes");
});
@ -39,9 +39,9 @@ it('Keyboard {bksp} button will work', () => {
it('Keyboard {space} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{space}", "test");
const output = keyboard.utilities.getUpdatedInput("{space}", "test");
expect(output).toBe("test ");
});
@ -49,9 +49,9 @@ it('Keyboard {space} button will work', () => {
it('Keyboard {tab} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{tab}", "test");
const output = keyboard.utilities.getUpdatedInput("{tab}", "test");
expect(output).toBe("test\t");
});
@ -59,11 +59,11 @@ it('Keyboard {tab} button will work', () => {
it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
tabCharOnTab: false
});
let output = keyboard.utilities.getUpdatedInput("{tab}", "test");
const output = keyboard.utilities.getUpdatedInput("{tab}", "test");
expect(output).toBe("test");
});
@ -71,9 +71,9 @@ it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
it('Keyboard {enter} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{enter}", "test");
const output = keyboard.utilities.getUpdatedInput("{enter}", "test");
expect(output).toBe("test");
});
@ -81,11 +81,11 @@ it('Keyboard {enter} button will work', () => {
it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
newLineOnEnter: true
});
let output = keyboard.utilities.getUpdatedInput("{enter}", "test");
const output = keyboard.utilities.getUpdatedInput("{enter}", "test");
expect(output).toBe("test\n");
});
@ -93,10 +93,10 @@ it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
it('Keyboard {numpadX} buttons will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
for(let i = 0;i<=9;i++){
let output = keyboard.utilities.getUpdatedInput(`{numpad${i}}`, "test");
const output = keyboard.utilities.getUpdatedInput(`{numpad${i}}`, "test");
expect(output).toBe(`test${i}`);
}
});
@ -104,9 +104,9 @@ it('Keyboard {numpadX} buttons will work', () => {
it('Keyboard {numpaddivide} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpaddivide}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpaddivide}", "test");
expect(output).toBe("test/");
});
@ -114,9 +114,9 @@ it('Keyboard {numpaddivide} button will work', () => {
it('Keyboard {numpadmultiply} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpadmultiply}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpadmultiply}", "test");
expect(output).toBe("test*");
});
@ -124,9 +124,9 @@ it('Keyboard {numpadmultiply} button will work', () => {
it('Keyboard {numpadsubtract} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpadsubtract}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpadsubtract}", "test");
expect(output).toBe("test-");
});
@ -134,9 +134,9 @@ it('Keyboard {numpadsubtract} button will work', () => {
it('Keyboard {numpadadd} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
expect(output).toBe("test+");
});
@ -144,9 +144,9 @@ it('Keyboard {numpadadd} button will work', () => {
it('Keyboard {numpadadd} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpadadd}", "test");
expect(output).toBe("test+");
});
@ -154,9 +154,9 @@ it('Keyboard {numpadadd} button will work', () => {
it('Keyboard {numpaddecimal} button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{numpaddecimal}", "test");
const output = keyboard.utilities.getUpdatedInput("{numpaddecimal}", "test");
expect(output).toBe("test.");
});
@ -164,7 +164,7 @@ it('Keyboard {numpaddecimal} button will work', () => {
it('Keyboard custom function buttons will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
layout: {
default: [
"{randombuttontest}"
@ -172,7 +172,7 @@ it('Keyboard custom function buttons will work', () => {
}
});
let output = keyboard.utilities.getUpdatedInput("{randombuttontest}", "test");
const output = keyboard.utilities.getUpdatedInput("{randombuttontest}", "test");
expect(output).toBe("test");
expect(keyboard.getButtonElement("{randombuttontest}").onclick).toBeTruthy();
@ -181,9 +181,9 @@ it('Keyboard custom function buttons will work', () => {
it('Keyboard "{" button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("{", "test");
const output = keyboard.utilities.getUpdatedInput("{", "test");
expect(output).toBe("test{");
});
@ -191,9 +191,9 @@ it('Keyboard "{" button will work', () => {
it('Keyboard "}" button will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.getUpdatedInput("}", "test");
const output = keyboard.utilities.getUpdatedInput("}", "test");
expect(output).toBe("test}");
});
@ -201,11 +201,11 @@ it('Keyboard "}" button will work', () => {
it('Keyboard standard button will affect input', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
for (let i = 65; i <= 90; i++) {
let char = String.fromCharCode(i);
let output = keyboard.utilities.getUpdatedInput(char, "test");
const char = String.fromCharCode(i);
const output = keyboard.utilities.getUpdatedInput(char, "test");
expect(output).toBe(`test${char}`);
}
});
@ -213,7 +213,7 @@ it('Keyboard standard button will affect input', () => {
it('Keyboard updateCaretPos will work with minus', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
syncInstanceInputs: true
});
@ -226,7 +226,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
it('Keyboard updateCaretPos will work with minus', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretPosition = 5;
keyboard.utilities.updateCaretPos(2, true);
@ -237,7 +237,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
it('Keyboard updateCaretPos will work with plus', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretPosition = 5;
keyboard.utilities.updateCaretPos(2);
@ -248,7 +248,7 @@ it('Keyboard updateCaretPos will work with plus', () => {
it('Keyboard addStringAt will work with debug', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
@ -260,7 +260,7 @@ it('Keyboard addStringAt will work with debug', () => {
it('Keyboard addStringAt will work with position', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
@ -275,7 +275,7 @@ it('Keyboard addStringAt will work with position', () => {
it('Keyboard addStringAt will respect maxLength', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true,
maxLength: 4
});
@ -292,13 +292,13 @@ it('Keyboard addStringAt will respect maxLength', () => {
it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
const output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
expect(output).toBeFalsy();
});
@ -306,7 +306,7 @@ it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
it('Keyboard handleMaxLength will work with object maxLength', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: {
default: 4
}
@ -314,7 +314,7 @@ it('Keyboard handleMaxLength will work with object maxLength', () => {
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeTruthy();
});
@ -322,7 +322,7 @@ it('Keyboard handleMaxLength will work with object maxLength', () => {
it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: {
default: 4
},
@ -331,7 +331,7 @@ it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeTruthy();
});
@ -339,7 +339,7 @@ it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
it('Keyboard handleMaxLength will return false if obj maxLength not reached', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: {
default: 7
}
@ -347,7 +347,7 @@ it('Keyboard handleMaxLength will return false if obj maxLength not reached', ()
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeFalsy();
});
@ -356,13 +356,13 @@ it('Keyboard handleMaxLength will return false if obj maxLength not reached', ()
it('Keyboard handleMaxLength will work without debug', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: 4
});
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeTruthy();
});
@ -371,13 +371,13 @@ it('Keyboard handleMaxLength will work without debug', () => {
it('Keyboard handleMaxLength will work with numeric maxLength', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: 3
});
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBe(true);
});
@ -385,13 +385,13 @@ it('Keyboard handleMaxLength will work with numeric maxLength', () => {
it('Keyboard handleMaxLength wont work with non numeric or object maxLength', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: "wrong"
});
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeFalsy();
});
@ -399,14 +399,14 @@ it('Keyboard handleMaxLength wont work with non numeric or object maxLength', ()
it('Keyboard handleMaxLength wont work with non numeric or object maxLength (with debug)', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: "wrong",
debug: true
});
keyboard.setInput("test");
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
expect(output).toBeFalsy();
});
@ -414,11 +414,11 @@ it('Keyboard handleMaxLength wont work with non numeric or object maxLength (wit
it('Keyboard isMaxLengthReached will work', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
maxLength: 5
});
let output = keyboard.utilities.isMaxLengthReached();
const output = keyboard.utilities.isMaxLengthReached();
expect(output).toBeFalsy();
});
@ -426,7 +426,7 @@ it('Keyboard isMaxLengthReached will work', () => {
it('Keyboard removeAt will exit out on caretPosition:0', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.setInput("test");
keyboard.caretPosition = 0;
@ -442,7 +442,7 @@ it('Keyboard removeAt will exit out on caretPosition:0', () => {
it('Keyboard removeAt will remove multi-byte unicodes with caretPos>0', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
keyboard.caretPosition = 6;
let output = keyboard.utilities.removeAt("test\uD83D\uDE00", 6);
@ -456,7 +456,7 @@ it('Keyboard removeAt will remove multi-byte unicodes with caretPos>0', () => {
it('Keyboard removeAt will not remove multi-byte unicodes with caretPos:0', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
let output = keyboard.utilities.removeAt("\uD83D\uDE00");
expect(output).toBeFalsy();
@ -467,7 +467,7 @@ it('Keyboard removeAt will not remove multi-byte unicodes with caretPos:0', () =
it('Keyboard removeAt will remove regular strings', () => {
testUtil.setDOM();
let keyboard = new Keyboard({
const keyboard = new Keyboard({
debug: true
});
@ -482,12 +482,12 @@ it('Keyboard removeAt will remove regular strings', () => {
it('Keyboard will work with custom (and weird) class', () => {
testUtil.setDOM("my--weird--class");
let keyboard = new Keyboard(".my--weird--class");
const keyboard = new Keyboard(".my--weird--class");
expect(keyboard.keyboardDOMClass).toBe("my--weird--class");
});
it('Keyboard camelCase will work with empty strings', () => {
testUtil.setDOM();
let keyboard = new Keyboard();
const keyboard = new Keyboard();
expect(keyboard.utilities.camelCase()).toBeFalsy();
});