mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-04-17 23:28:36 +08:00
Linting codebase
This commit is contained in:
parent
7fd757cd02
commit
304f47701e
@ -43,8 +43,8 @@ class Demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleShift() {
|
handleShift() {
|
||||||
let currentLayout = this.keyboard.options.layoutName;
|
const currentLayout = this.keyboard.options.layoutName;
|
||||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||||
|
|
||||||
this.keyboard.setOptions({
|
this.keyboard.setOptions({
|
||||||
layoutName: shiftToggle
|
layoutName: shiftToggle
|
||||||
|
@ -61,8 +61,8 @@ class Demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleShift() {
|
handleShift() {
|
||||||
let currentLayout = this.keyboard.options.layoutName;
|
const currentLayout = this.keyboard.options.layoutName;
|
||||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||||
|
|
||||||
this.keyboard.setOptions({
|
this.keyboard.setOptions({
|
||||||
layoutName: shiftToggle
|
layoutName: shiftToggle
|
||||||
|
@ -27,7 +27,7 @@ class Demo {
|
|||||||
/**
|
/**
|
||||||
* Demo Start
|
* Demo Start
|
||||||
*/
|
*/
|
||||||
let commonKeyboardOptions = {
|
const commonKeyboardOptions = {
|
||||||
onChange: input => this.onChange(input),
|
onChange: input => this.onChange(input),
|
||||||
onKeyPress: button => this.onKeyPress(button),
|
onKeyPress: button => this.onKeyPress(button),
|
||||||
theme: "simple-keyboard hg-theme-default hg-layout-default",
|
theme: "simple-keyboard hg-theme-default hg-layout-default",
|
||||||
@ -116,8 +116,8 @@ class Demo {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector(".input").addEventListener("input", event => {
|
document.querySelector(".input").addEventListener("input", () => {
|
||||||
let input = document.querySelector(".input").value;
|
const input = document.querySelector(".input").value;
|
||||||
this.keyboard.setInput(input);
|
this.keyboard.setInput(input);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -145,8 +145,8 @@ class Demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleShift() {
|
handleShift() {
|
||||||
let currentLayout = this.keyboard.options.layoutName;
|
const currentLayout = this.keyboard.options.layoutName;
|
||||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||||
|
|
||||||
this.keyboard.setOptions({
|
this.keyboard.setOptions({
|
||||||
layoutName: shiftToggle
|
layoutName: shiftToggle
|
||||||
|
@ -76,9 +76,9 @@ class Demo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleShift(keyboardInstanceKey) {
|
handleShift(keyboardInstanceKey) {
|
||||||
let keyboard = this[keyboardInstanceKey || "keyboard"];
|
const keyboard = this[keyboardInstanceKey || "keyboard"];
|
||||||
let currentLayout = keyboard.options.layoutName;
|
const currentLayout = keyboard.options.layoutName;
|
||||||
let shiftToggle = currentLayout === "default" ? "shift" : "default";
|
const shiftToggle = currentLayout === "default" ? "shift" : "default";
|
||||||
|
|
||||||
keyboard.setOptions({
|
keyboard.setOptions({
|
||||||
layoutName: shiftToggle
|
layoutName: shiftToggle
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import TestUtility from '../../utils/TestUtility';
|
import TestUtility from '../../utils/TestUtility';
|
||||||
import BasicDemo from '../BasicDemo';
|
import BasicDemo from '../BasicDemo';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Demo will load', () => {
|
it('Demo will load', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
new BasicDemo();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Demo onDOMLoaded will work', () => {
|
it('Demo onDOMLoaded will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
const demo = new BasicDemo();
|
||||||
|
|
||||||
expect(demo.keyboard).toBeTruthy();
|
expect(demo.keyboard).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
const demo = new BasicDemo();
|
||||||
|
|
||||||
demo.onChange("test");
|
demo.onChange("test");
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
const demo = new BasicDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("q").onclick();
|
demo.keyboard.getButtonElement("q").onclick();
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo input change will work', () => {
|
it('Demo input change will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
const demo = new BasicDemo();
|
||||||
|
|
||||||
document.body.querySelector('.input').value = "test";
|
document.body.querySelector('.input').value = "test";
|
||||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||||
@ -51,7 +51,7 @@ it('Demo input change will work', () => {
|
|||||||
it('Demo handleShiftButton will work', () => {
|
it('Demo handleShiftButton will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new BasicDemo();
|
const demo = new BasicDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import TestUtility from '../../utils/TestUtility';
|
import TestUtility from '../../utils/TestUtility';
|
||||||
import ButtonThemeDemo from '../ButtonThemeDemo';
|
import ButtonThemeDemo from '../ButtonThemeDemo';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Demo will load', () => {
|
it('Demo will load', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
new ButtonThemeDemo();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Demo onDOMLoaded will work', () => {
|
it('Demo onDOMLoaded will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
const demo = new ButtonThemeDemo();
|
||||||
|
|
||||||
expect(demo.keyboard).toBeTruthy();
|
expect(demo.keyboard).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -20,7 +20,7 @@ it('Demo onDOMLoaded will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
const demo = new ButtonThemeDemo();
|
||||||
|
|
||||||
demo.onChange("test");
|
demo.onChange("test");
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
const demo = new ButtonThemeDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("q").onclick();
|
demo.keyboard.getButtonElement("q").onclick();
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo input change will work', () => {
|
it('Demo input change will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
const demo = new ButtonThemeDemo();
|
||||||
|
|
||||||
document.body.querySelector('.input').value = "test";
|
document.body.querySelector('.input').value = "test";
|
||||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||||
@ -51,7 +51,7 @@ it('Demo input change will work', () => {
|
|||||||
it('Demo handleShiftButton will work', () => {
|
it('Demo handleShiftButton will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new ButtonThemeDemo();
|
const demo = new ButtonThemeDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
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', () => {
|
it('Demo buttons will have proper attributes and classes', () => {
|
||||||
testUtil.setDOM();
|
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);
|
console.log("buttonDOM", buttonDOM.outerHTML);
|
||||||
|
|
||||||
let hasAttribute = buttonDOM.hasAttribute("aria-label");
|
const hasAttribute = buttonDOM.hasAttribute("aria-label");
|
||||||
expect(hasAttribute).toBeTruthy();
|
expect(hasAttribute).toBeTruthy();
|
||||||
|
|
||||||
let hasClass = buttonDOM.classList.contains("my-button-outline");
|
const hasClass = buttonDOM.classList.contains("my-button-outline");
|
||||||
expect(hasClass).toBeTruthy();
|
expect(hasClass).toBeTruthy();
|
||||||
});
|
});
|
@ -1,18 +1,17 @@
|
|||||||
import TestUtility from '../../utils/TestUtility';
|
import TestUtility from '../../utils/TestUtility';
|
||||||
import FullKeyboardDemo from '../FullKeyboardDemo';
|
import FullKeyboardDemo from '../FullKeyboardDemo';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Demo will load', () => {
|
it('Demo will load', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
new FullKeyboardDemo();
|
||||||
let demo = new FullKeyboardDemo();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Demo onDOMLoaded will work', () => {
|
it('Demo onDOMLoaded will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new FullKeyboardDemo();
|
const demo = new FullKeyboardDemo();
|
||||||
|
|
||||||
expect(demo.keyboard).toBeTruthy();
|
expect(demo.keyboard).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -20,7 +19,7 @@ it('Demo onDOMLoaded will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new FullKeyboardDemo();
|
const demo = new FullKeyboardDemo();
|
||||||
|
|
||||||
demo.onChange("test");
|
demo.onChange("test");
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new FullKeyboardDemo();
|
const demo = new FullKeyboardDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("q").onclick();
|
demo.keyboard.getButtonElement("q").onclick();
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo input change will work', () => {
|
it('Demo input change will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new FullKeyboardDemo();
|
const demo = new FullKeyboardDemo();
|
||||||
|
|
||||||
document.body.querySelector('.input').value = "test";
|
document.body.querySelector('.input').value = "test";
|
||||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||||
@ -52,7 +51,7 @@ it('Demo input change will work', () => {
|
|||||||
it('Demo handleShiftButton will work', () => {
|
it('Demo handleShiftButton will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new FullKeyboardDemo();
|
const demo = new FullKeyboardDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("{shiftleft}").onclick();
|
demo.keyboard.getButtonElement("{shiftleft}").onclick();
|
||||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||||
|
@ -3,18 +3,18 @@ import MultipleKeyboardsDestroyDemo from '../MultipleKeyboardsDestroyDemo';
|
|||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Demo will load', () => {
|
it('Demo will load', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
new MultipleKeyboardsDestroyDemo();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Demo onDOMLoaded will work', () => {
|
it('Demo onDOMLoaded will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
|
|
||||||
expect(demo.keyboard).toBeTruthy();
|
expect(demo.keyboard).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -22,7 +22,7 @@ it('Demo onDOMLoaded will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
|
|
||||||
demo.onChange("test");
|
demo.onChange("test");
|
||||||
demo.keyboard2.getButtonElement("q").click();
|
demo.keyboard2.getButtonElement("q").click();
|
||||||
@ -34,7 +34,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo onChange will work', () => {
|
it('Demo onChange will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("q").onclick();
|
demo.keyboard.getButtonElement("q").onclick();
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ it('Demo onChange will work', () => {
|
|||||||
it('Demo input change will work', () => {
|
it('Demo input change will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
|
|
||||||
document.body.querySelector('.input').value = "test";
|
document.body.querySelector('.input').value = "test";
|
||||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||||
@ -59,7 +59,7 @@ it('Demo input change will work', () => {
|
|||||||
it('Demo handleShiftButton will work', () => {
|
it('Demo handleShiftButton will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
|
|
||||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||||
@ -71,7 +71,7 @@ it('Demo handleShiftButton will work', () => {
|
|||||||
it('MultipleKeyboardsDestroyDemo will run all timers', () => {
|
it('MultipleKeyboardsDestroyDemo will run all timers', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let demo = new MultipleKeyboardsDestroyDemo();
|
const demo = new MultipleKeyboardsDestroyDemo();
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
|
|
||||||
expect(demo.keyboard.options.theme).toBe("hg-theme-default myTheme");
|
expect(demo.keyboard.options.theme).toBe("hg-theme-default myTheme");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Keyboard from '../Keyboard';
|
import Keyboard from '../Keyboard';
|
||||||
import TestUtility from '../../../utils/TestUtility';
|
import TestUtility from '../../../utils/TestUtility';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Keyboard will not render without target element', () => {
|
it('Keyboard will not render without target element', () => {
|
||||||
try {
|
try {
|
||||||
@ -38,7 +38,7 @@ it('Keyboard will run with custom DOM target', () => {
|
|||||||
it('Keyboard will run with debug option set', () => {
|
it('Keyboard will run with debug option set', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,10 +51,10 @@ it('Keyboard will use touch events', () => {
|
|||||||
testUtil.clear()
|
testUtil.clear()
|
||||||
|
|
||||||
document.body.innerHTML = `
|
document.body.innerHTML = `
|
||||||
<div id="keyboard"></div>
|
<div class="keyboard"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const keyboard = new Keyboard('#keyboard', {
|
const keyboard = new Keyboard('.keyboard', {
|
||||||
useTouchEvents: true,
|
useTouchEvents: true,
|
||||||
onChange: () => touched = true,
|
onChange: () => touched = true,
|
||||||
layout: {
|
layout: {
|
||||||
@ -73,7 +73,7 @@ it('Keyboard will use touch events', () => {
|
|||||||
|
|
||||||
it('Keyboard standard buttons will work', () => {
|
it('Keyboard standard buttons will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: {
|
maxLength: {
|
||||||
"default": 10
|
"default": 10
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ it('Keyboard standard buttons will work', () => {
|
|||||||
|
|
||||||
it('Keyboard shift buttons will work', () => {
|
it('Keyboard shift buttons will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.setOptions({
|
keyboard.setOptions({
|
||||||
layoutName: "shift",
|
layoutName: "shift",
|
||||||
@ -97,7 +97,7 @@ it('Keyboard shift buttons will work', () => {
|
|||||||
|
|
||||||
it('Keyboard setOptions will work without a param', () => {
|
it('Keyboard setOptions will work without a param', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.setOptions();
|
keyboard.setOptions();
|
||||||
});
|
});
|
||||||
@ -105,7 +105,7 @@ it('Keyboard setOptions will work without a param', () => {
|
|||||||
it('Keyboard empty buttons wont do anything as expected', () => {
|
it('Keyboard empty buttons wont do anything as expected', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
layout: {
|
layout: {
|
||||||
default: [
|
default: [
|
||||||
"{//} {button} d",
|
"{//} {button} d",
|
||||||
@ -122,7 +122,7 @@ it('Keyboard onKeyPress will work', () => {
|
|||||||
|
|
||||||
let pressed = false;
|
let pressed = false;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
onKeyPress: () => {
|
onKeyPress: () => {
|
||||||
pressed = true;
|
pressed = true;
|
||||||
},
|
},
|
||||||
@ -137,7 +137,7 @@ it('Keyboard onKeyPress will work', () => {
|
|||||||
it('Keyboard standard function buttons will not change input', () => {
|
it('Keyboard standard function buttons will not change input', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
useButtonTag: true
|
useButtonTag: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ it('Keyboard syncInstanceInputs will work', () => {
|
|||||||
<div class="keyboard2"></div>
|
<div class="keyboard2"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let sharedOptions = {
|
const sharedOptions = {
|
||||||
syncInstanceInputs: true
|
syncInstanceInputs: true
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ it('Keyboard onChange will work', () => {
|
|||||||
|
|
||||||
let output = false;
|
let output = false;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
onChange: (input) => {
|
onChange: (input) => {
|
||||||
output = input;
|
output = input;
|
||||||
},
|
},
|
||||||
@ -212,7 +212,7 @@ it('Keyboard onChangeAll will work', () => {
|
|||||||
|
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
onChangeAll: (input) => {
|
onChangeAll: (input) => {
|
||||||
output = input ? input.default : null;
|
output = input ? input.default : null;
|
||||||
},
|
},
|
||||||
@ -227,7 +227,7 @@ it('Keyboard onChangeAll will work', () => {
|
|||||||
it('Keyboard clearInput will work', () => {
|
it('Keyboard clearInput will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Avoid setInput for this test
|
* Avoid setInput for this test
|
||||||
@ -249,12 +249,12 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
|
|||||||
<div class="keyboard2"></div>
|
<div class="keyboard2"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let sharedOptions = {
|
const sharedOptions = {
|
||||||
syncInstanceInputs: true
|
syncInstanceInputs: true
|
||||||
};
|
};
|
||||||
|
|
||||||
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||||
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Avoid setInput for this test
|
* Avoid setInput for this test
|
||||||
@ -271,7 +271,7 @@ it('Keyboard clearInput will work with syncInstanceInputs', () => {
|
|||||||
it('Keyboard setInput will work', () => {
|
it('Keyboard setInput will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.setInput("hello");
|
keyboard.setInput("hello");
|
||||||
|
|
||||||
@ -286,12 +286,12 @@ it('Keyboard setInput will work with syncInstanceInputs', () => {
|
|||||||
<div class="keyboard2"></div>
|
<div class="keyboard2"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let sharedOptions = {
|
const sharedOptions = {
|
||||||
syncInstanceInputs: true
|
syncInstanceInputs: true
|
||||||
};
|
};
|
||||||
|
|
||||||
let keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
const keyboard1 = new Keyboard(".keyboard1", sharedOptions);
|
||||||
let keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
const keyboard2 = new Keyboard(".keyboard2", sharedOptions);
|
||||||
|
|
||||||
keyboard1.setInput("hello");
|
keyboard1.setInput("hello");
|
||||||
|
|
||||||
@ -306,8 +306,8 @@ it('Keyboard dispatch will work', () => {
|
|||||||
<div class="keyboard2"></div>
|
<div class="keyboard2"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let keyboard1 = new Keyboard(".keyboard1");
|
const keyboard1 = new Keyboard(".keyboard1");
|
||||||
let keyboard2 = new Keyboard(".keyboard2");
|
const keyboard2 = new Keyboard(".keyboard2");
|
||||||
|
|
||||||
keyboard1.dispatch(instance => {
|
keyboard1.dispatch(instance => {
|
||||||
instance.setOptions({
|
instance.setOptions({
|
||||||
@ -331,8 +331,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
|
|||||||
<div class="keyboard2"></div>
|
<div class="keyboard2"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let keyboard1 = new Keyboard(".keyboard1");
|
const keyboard1 = new Keyboard(".keyboard1");
|
||||||
let keyboard2 = new Keyboard(".keyboard2");
|
new Keyboard(".keyboard2");
|
||||||
|
|
||||||
window['SimpleKeyboardInstances'] = null;
|
window['SimpleKeyboardInstances'] = null;
|
||||||
|
|
||||||
@ -357,8 +357,8 @@ it('Keyboard dispatch will not work without SimpleKeyboardInstances', () => {
|
|||||||
it('Keyboard addButtonTheme will work', () => {
|
it('Keyboard addButtonTheme will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
let returnVal = keyboard.addButtonTheme("q", "test");
|
keyboard.addButtonTheme("q", "test");
|
||||||
|
|
||||||
expect(keyboard.options.buttonTheme[0].class).toBe("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', () => {
|
it('Keyboard addButtonTheme will not work without params', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
let returnVal = keyboard.addButtonTheme();
|
const returnVal = keyboard.addButtonTheme();
|
||||||
|
|
||||||
expect(returnVal).toBeFalsy();
|
expect(returnVal).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -375,7 +375,7 @@ it('Keyboard addButtonTheme will not work without params', () => {
|
|||||||
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -392,7 +392,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
|||||||
it('Keyboard addButtonTheme will create a buttonTheme', () => {
|
it('Keyboard addButtonTheme will create a buttonTheme', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "blurb",
|
class: "blurb",
|
||||||
@ -409,7 +409,7 @@ it('Keyboard addButtonTheme will create a buttonTheme', () => {
|
|||||||
it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
|
it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -426,7 +426,7 @@ it('Keyboard addButtonTheme will ignore a repeated buttonTheme', () => {
|
|||||||
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -444,7 +444,7 @@ it('Keyboard addButtonTheme will amend a buttonTheme', () => {
|
|||||||
it('Keyboard removeButtonTheme without params will remove all button themes', () => {
|
it('Keyboard removeButtonTheme without params will remove all button themes', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -462,7 +462,7 @@ it('Keyboard removeButtonTheme without params will remove all button themes', ()
|
|||||||
it('Keyboard removeButtonTheme will work', () => {
|
it('Keyboard removeButtonTheme will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -479,7 +479,7 @@ it('Keyboard removeButtonTheme will work', () => {
|
|||||||
it('Keyboard removeButtonTheme will work wihtout a class', () => {
|
it('Keyboard removeButtonTheme will work wihtout a class', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -496,7 +496,7 @@ it('Keyboard removeButtonTheme will work wihtout a class', () => {
|
|||||||
it('Keyboard removeButtonTheme will do nothing without a button param', () => {
|
it('Keyboard removeButtonTheme will do nothing without a button param', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
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', () => {
|
it('Keyboard removeButtonTheme does nothing if req button doesnt have a buttonTheme', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
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', () => {
|
it('Keyboard removeButtonTheme does nothing if buttonTheme class does not exist', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "testy",
|
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', () => {
|
it('Keyboard removeButtonTheme does nothing if buttonTheme doesnt have the requested buttons', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
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', () => {
|
it('Keyboard getButtonElement will not return anything if empty match', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
layout: {
|
layout: {
|
||||||
default: [
|
default: [
|
||||||
"{//} {button} d",
|
"{//} {button} d",
|
||||||
@ -579,7 +579,7 @@ it('Keyboard getButtonElement will not return anything if empty match', () => {
|
|||||||
it('Keyboard getButtonElement will return multiple matched buttons', () => {
|
it('Keyboard getButtonElement will return multiple matched buttons', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
expect(keyboard.getButtonElement("{shift}").length).toBe(2);
|
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', () => {
|
it('Keyboard caretEventHandler will detect input, textarea focus', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretEventHandler({
|
keyboard.caretEventHandler({
|
||||||
charCode: 0,
|
charCode: 0,
|
||||||
@ -625,7 +625,7 @@ it('Keyboard caretEventHandler will detect input, textarea focus', () => {
|
|||||||
it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositioning', () => {
|
it('Keyboard caretEventHandler will not set caretPosition on disableCaretPositioning', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretEventHandler({
|
keyboard.caretEventHandler({
|
||||||
charCode: 0,
|
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', () => {
|
it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.isMouseHold = true;
|
keyboard.isMouseHold = true;
|
||||||
|
|
||||||
@ -682,7 +682,7 @@ it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', (
|
|||||||
it('Keyboard caretEventHandler will work with debug', () => {
|
it('Keyboard caretEventHandler will work with debug', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -705,7 +705,7 @@ it('Keyboard onInit will work', () => {
|
|||||||
|
|
||||||
let passed = false;
|
let passed = false;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
onInit: () => {
|
onInit: () => {
|
||||||
passed = true
|
passed = true
|
||||||
}
|
}
|
||||||
@ -719,7 +719,7 @@ it('Keyboard onRender will work', () => {
|
|||||||
|
|
||||||
let passed = false;
|
let passed = false;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
onRender: () => {
|
onRender: () => {
|
||||||
passed = true
|
passed = true
|
||||||
}
|
}
|
||||||
@ -731,7 +731,7 @@ it('Keyboard onRender will work', () => {
|
|||||||
it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
|
it('Keyboard buttonTheme that is invalid will be ignored and not throw', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: null,
|
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', () => {
|
it('Keyboard buttonTheme buttons that are invalid will be ignored and not throw', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: null,
|
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', () => {
|
it('Keyboard buttonTheme will be ignored if already added', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
buttonTheme: [
|
buttonTheme: [
|
||||||
{
|
{
|
||||||
class: "test",
|
class: "test",
|
||||||
@ -801,7 +801,7 @@ it('Keyboard buttonTheme will be ignored if already added', () => {
|
|||||||
it('Keyboard can set a module', () => {
|
it('Keyboard can set a module', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.registerModule(
|
keyboard.registerModule(
|
||||||
"test",
|
"test",
|
||||||
@ -816,7 +816,7 @@ it('Keyboard can set a module', () => {
|
|||||||
it('Keyboard registerModule will return current module tree', () => {
|
it('Keyboard registerModule will return current module tree', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.modules.test = {
|
keyboard.modules.test = {
|
||||||
testy: "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', () => {
|
it('Keyboard can set a module by amending the modules tree', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.modules = {
|
keyboard.modules = {
|
||||||
testman: {
|
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', () => {
|
it('Keyboard will not retrieve an option for an inexistent module', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
expect(keyboard.getModuleProp("test", "foo")).toBeFalsy();
|
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', () => {
|
it('Keyboard will get a list of modules', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.registerModule(
|
keyboard.registerModule(
|
||||||
"test",
|
"test",
|
||||||
@ -886,7 +886,7 @@ it('Keyboard loadModules will load a simple module', () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
modules: [
|
modules: [
|
||||||
myClass
|
myClass
|
||||||
]
|
]
|
||||||
@ -896,7 +896,7 @@ it('Keyboard loadModules will load a simple module', () => {
|
|||||||
it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
|
it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.isMouseHold = true;
|
keyboard.isMouseHold = true;
|
||||||
|
|
||||||
@ -908,7 +908,7 @@ it('Keyboard handleButtonMouseUp will set isMouseHold to false', () => {
|
|||||||
it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
|
it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.isMouseHold = true;
|
keyboard.isMouseHold = true;
|
||||||
keyboard.holdInteractionTimeout = setTimeout(() => {}, 10000);
|
keyboard.holdInteractionTimeout = setTimeout(() => {}, 10000);
|
||||||
@ -919,7 +919,7 @@ it('Keyboard handleButtonMouseUp clear holdInteractionTimeout', () => {
|
|||||||
it('Keyboard handleButtonMouseDown will work', () => {
|
it('Keyboard handleButtonMouseDown will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.handleButtonMouseDown("q", {
|
keyboard.handleButtonMouseDown("q", {
|
||||||
target: keyboard.getButtonElement("q"),
|
target: keyboard.getButtonElement("q"),
|
||||||
@ -937,7 +937,7 @@ it('Keyboard handleButtonMouseDown will work', () => {
|
|||||||
it('Keyboard handleButtonMouseDown will work with preventMouseDownDefault', () => {
|
it('Keyboard handleButtonMouseDown will work with preventMouseDownDefault', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.options.preventMouseDownDefault = true;
|
keyboard.options.preventMouseDownDefault = true;
|
||||||
|
|
||||||
@ -965,7 +965,7 @@ it('Keyboard onModulesLoaded will work', () => {
|
|||||||
|
|
||||||
let foo;
|
let foo;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
modules: [
|
modules: [
|
||||||
myClass
|
myClass
|
||||||
],
|
],
|
||||||
@ -980,7 +980,7 @@ it('Keyboard onModulesLoaded will work', () => {
|
|||||||
it('Keyboard inputPattern will work globally', () => {
|
it('Keyboard inputPattern will work globally', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
inputPattern: /^\d+$/,
|
inputPattern: /^\d+$/,
|
||||||
useMouseEvents: true
|
useMouseEvents: true
|
||||||
});
|
});
|
||||||
@ -997,7 +997,7 @@ it('Keyboard inputPattern will work globally', () => {
|
|||||||
it('Keyboard inputPattern will work by input name', () => {
|
it('Keyboard inputPattern will work by input name', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true,
|
debug: true,
|
||||||
inputName: "test1",
|
inputName: "test1",
|
||||||
inputPattern: {
|
inputPattern: {
|
||||||
@ -1026,7 +1026,7 @@ it('Keyboard processAutoTouchEvents will work', () => {
|
|||||||
|
|
||||||
navigator.maxTouchPoints = true;
|
navigator.maxTouchPoints = true;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
autoUseTouchEvents: true
|
autoUseTouchEvents: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ it('Keyboard processAutoTouchEvents will work with debugging enabled', () => {
|
|||||||
|
|
||||||
navigator.maxTouchPoints = true;
|
navigator.maxTouchPoints = true;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
autoUseTouchEvents: true,
|
autoUseTouchEvents: true,
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
@ -1051,7 +1051,7 @@ it('Keyboard beforeFirstRender method will work', () => {
|
|||||||
|
|
||||||
let timesCalled = 0;
|
let timesCalled = 0;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
beforeFirstRender: () => {
|
beforeFirstRender: () => {
|
||||||
timesCalled++;
|
timesCalled++;
|
||||||
}
|
}
|
||||||
@ -1074,7 +1074,7 @@ it('Keyboard beforeFirstRender will show PointerEvents warning', () => {
|
|||||||
|
|
||||||
window.PointerEvent = window.PointerEvent ? window.PointerEvent : () => {};
|
window.PointerEvent = window.PointerEvent ? window.PointerEvent : () => {};
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
debug: true,
|
debug: true,
|
||||||
beforeFirstRender: () => {
|
beforeFirstRender: () => {
|
||||||
timesCalled++;
|
timesCalled++;
|
||||||
@ -1089,7 +1089,7 @@ it('Keyboard beforeRender method will work', () => {
|
|||||||
|
|
||||||
let timesCalled = 0;
|
let timesCalled = 0;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
beforeRender: () => {
|
beforeRender: () => {
|
||||||
timesCalled++;
|
timesCalled++;
|
||||||
}
|
}
|
||||||
@ -1108,7 +1108,7 @@ it('Keyboard beforeRender method will work', () => {
|
|||||||
it('Keyboard parseRowDOMContainers will work', () => {
|
it('Keyboard parseRowDOMContainers will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
layout: {
|
layout: {
|
||||||
'default': [
|
'default': [
|
||||||
'` [1 2 3 4 5 6 7 8 9] 0 - = {bksp}',
|
'` [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);
|
expect(containers.length).toBe(5);
|
||||||
|
|
||||||
@ -1144,7 +1144,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
|
|||||||
let failed = false;
|
let failed = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
keyboard.parseRowDOMContainers({
|
keyboard.parseRowDOMContainers({
|
||||||
children: []
|
children: []
|
||||||
});
|
});
|
||||||
@ -1159,7 +1159,7 @@ it('Keyboard parseRowDOMContainers will ignore empty rows', () => {
|
|||||||
it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex before startIndex', () => {
|
it('Keyboard parseRowDOMContainers will ignore missing endIndex or endIndex before startIndex', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
layout: {
|
layout: {
|
||||||
'default': [
|
'default': [
|
||||||
'` [1 2 3 4 5 6 7 8 9 0 - = {bksp}',
|
'` [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);
|
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', () => {
|
it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
disableRowButtonContainers: true,
|
disableRowButtonContainers: true,
|
||||||
layout: {
|
layout: {
|
||||||
'default': [
|
'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);
|
expect(containers.length).toBe(0);
|
||||||
});
|
});
|
||||||
@ -1204,7 +1204,7 @@ it('Keyboard disableRowButtonContainers will bypass parseRowDOMContainers', () =
|
|||||||
it('Keyboard inputName change will trigget caretPosition reset', () => {
|
it('Keyboard inputName change will trigget caretPosition reset', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretPosition = 0;
|
keyboard.caretPosition = 0;
|
||||||
|
|
||||||
@ -1227,7 +1227,7 @@ it('Keyboard inputName change will trigget caretPosition reset', () => {
|
|||||||
it('Keyboard destroy will work', () => {
|
it('Keyboard destroy will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
keyboard.destroy();
|
keyboard.destroy();
|
||||||
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
||||||
});
|
});
|
||||||
@ -1235,7 +1235,7 @@ it('Keyboard destroy will work', () => {
|
|||||||
it('Keyboard destroy will work with debug option', () => {
|
it('Keyboard destroy will work with debug option', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({ debug: true });
|
const keyboard = new Keyboard({ debug: true });
|
||||||
keyboard.destroy();
|
keyboard.destroy();
|
||||||
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
expect(keyboard.keyboardDOM.innerHTML).toBe("");
|
||||||
});
|
});
|
||||||
@ -1243,7 +1243,7 @@ it('Keyboard destroy will work with debug option', () => {
|
|||||||
it('Keyboard disableButtonHold will work', () => {
|
it('Keyboard disableButtonHold will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
disableButtonHold: true
|
disableButtonHold: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1253,7 +1253,7 @@ it('Keyboard disableButtonHold will work', () => {
|
|||||||
it('Keyboard caretEventHandler will be triggered on mouseup and ontouchend', () => {
|
it('Keyboard caretEventHandler will be triggered on mouseup and ontouchend', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
disableCaretPositioning: true
|
disableCaretPositioning: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1289,7 +1289,7 @@ it('Keyboard onKeyReleased will work', () => {
|
|||||||
let firedTimes = 0;
|
let firedTimes = 0;
|
||||||
let buttonPressed;
|
let buttonPressed;
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
onKeyReleased: button => {
|
onKeyReleased: button => {
|
||||||
pressed = true;
|
pressed = true;
|
||||||
buttonPressed = button;
|
buttonPressed = button;
|
||||||
@ -1309,7 +1309,7 @@ it('Keyboard onKeyReleased will work', () => {
|
|||||||
it('Keyboard buttonAttribute will work', () => {
|
it('Keyboard buttonAttribute will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
buttonAttributes: [
|
buttonAttributes: [
|
||||||
{
|
{
|
||||||
attribute: "aria-label",
|
attribute: "aria-label",
|
||||||
@ -1323,7 +1323,7 @@ it('Keyboard buttonAttribute will work', () => {
|
|||||||
it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
buttonAttributes: [
|
buttonAttributes: [
|
||||||
{
|
{
|
||||||
attribute: false,
|
attribute: false,
|
||||||
@ -1335,6 +1335,6 @@ it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
|||||||
|
|
||||||
it('Keyboard recurseButtons will not work without a valid param', () => {
|
it('Keyboard recurseButtons will not work without a valid param', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
expect(keyboard.recurseButtons()).toBe(false);
|
expect(keyboard.recurseButtons()).toBe(false);
|
||||||
});
|
});
|
||||||
|
@ -1,29 +1,18 @@
|
|||||||
/**
|
export const getDefaultLayout = () => {
|
||||||
* Keyboard Layout Service
|
return {
|
||||||
*/
|
default: [
|
||||||
class KeyboardLayout {
|
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
|
||||||
/**
|
"{tab} q w e r t y u i o p [ ] \\",
|
||||||
* Get default simple-keyboard layout
|
"{lock} a s d f g h j k l ; ' {enter}",
|
||||||
* @return {object} The default layout (US-QWERTY)
|
"{shift} z x c v b n m , . / {shift}",
|
||||||
*/
|
".com @ {space}"
|
||||||
static getDefaultLayout() {
|
],
|
||||||
return {
|
shift: [
|
||||||
default: [
|
"~ ! @ # $ % ^ & * ( ) _ + {bksp}",
|
||||||
"` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",
|
"{tab} Q W E R T Y U I O P { } |",
|
||||||
"{tab} q w e r t y u i o p [ ] \\",
|
'{lock} A S D F G H J K L : " {enter}',
|
||||||
"{lock} a s d f g h j k l ; ' {enter}",
|
"{shift} Z X C V B N M < > ? {shift}",
|
||||||
"{shift} z x c v b n m , . / {shift}",
|
".com @ {space}"
|
||||||
".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;
|
|
||||||
|
@ -21,11 +21,11 @@ class PhysicalKeyboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleHighlightKeyDown(event) {
|
handleHighlightKeyDown(event) {
|
||||||
let options = this.getOptions();
|
const options = this.getOptions();
|
||||||
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
|
|
||||||
this.dispatch(instance => {
|
this.dispatch(instance => {
|
||||||
let buttonDOM =
|
const buttonDOM =
|
||||||
instance.getButtonElement(buttonPressed) ||
|
instance.getButtonElement(buttonPressed) ||
|
||||||
instance.getButtonElement(`{${buttonPressed}}`);
|
instance.getButtonElement(`{${buttonPressed}}`);
|
||||||
|
|
||||||
@ -39,10 +39,10 @@ class PhysicalKeyboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleHighlightKeyUp(event) {
|
handleHighlightKeyUp(event) {
|
||||||
let buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
|
|
||||||
this.dispatch(instance => {
|
this.dispatch(instance => {
|
||||||
let buttonDOM =
|
const buttonDOM =
|
||||||
instance.getButtonElement(buttonPressed) ||
|
instance.getButtonElement(buttonPressed) ||
|
||||||
instance.getButtonElement(`{${buttonPressed}}`);
|
instance.getButtonElement(`{${buttonPressed}}`);
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import Keyboard from '../../components/Keyboard';
|
import Keyboard from '../../components/Keyboard';
|
||||||
import TestUtility from '../../../utils/TestUtility';
|
import TestUtility from '../../../utils/TestUtility';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', () => {
|
it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true
|
physicalKeyboardHighlight: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ it('PhysicalKeyboard keydown will be handled with physicalKeyboardHighlight', ()
|
|||||||
it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight', () => {
|
it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: false
|
physicalKeyboardHighlight: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ it('PhysicalKeyboard keydown will be handled without physicalKeyboardHighlight',
|
|||||||
it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
|
it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true
|
physicalKeyboardHighlight: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ it('PhysicalKeyboard keydown will not style non-existent buttons', () => {
|
|||||||
it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () => {
|
it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true
|
physicalKeyboardHighlight: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ it('PhysicalKeyboard keyup will be handled with physicalKeyboardHighlight', () =
|
|||||||
it('PhysicalKeyboard keyup will be handle special buttons', () => {
|
it('PhysicalKeyboard keyup will be handle special buttons', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true
|
physicalKeyboardHighlight: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ it('PhysicalKeyboard keyup will be handle special buttons', () => {
|
|||||||
it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
|
it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true,
|
physicalKeyboardHighlight: true,
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
@ -103,7 +103,7 @@ it('PhysicalKeyboard keyup will not style non-existent buttons', () => {
|
|||||||
it('PhysicalKeyboard will work with F1-F12 keys', () => {
|
it('PhysicalKeyboard will work with F1-F12 keys', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
new Keyboard({
|
||||||
physicalKeyboardHighlight: true,
|
physicalKeyboardHighlight: true,
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import Keyboard from '../../components/Keyboard';
|
import Keyboard from '../../components/Keyboard';
|
||||||
import TestUtility from '../../../utils/TestUtility';
|
import TestUtility from '../../../utils/TestUtility';
|
||||||
|
|
||||||
let testUtil = new TestUtility();
|
const testUtil = new TestUtility();
|
||||||
|
|
||||||
it('Keyboard mergeDisplay will work', () => {
|
it('Keyboard mergeDisplay will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
mergeDisplay: true,
|
mergeDisplay: true,
|
||||||
display: {
|
display: {
|
||||||
"q": "qreplaced"
|
"q": "qreplaced"
|
||||||
@ -29,9 +29,9 @@ it('Keyboard function buttons will work', () => {
|
|||||||
it('Keyboard {bksp} button will work', () => {
|
it('Keyboard {bksp} button will work', () => {
|
||||||
testUtil.setDOM();
|
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");
|
expect(output).toBe("tes");
|
||||||
});
|
});
|
||||||
@ -39,9 +39,9 @@ it('Keyboard {bksp} button will work', () => {
|
|||||||
it('Keyboard {space} button will work', () => {
|
it('Keyboard {space} button will work', () => {
|
||||||
testUtil.setDOM();
|
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 ");
|
expect(output).toBe("test ");
|
||||||
});
|
});
|
||||||
@ -49,9 +49,9 @@ it('Keyboard {space} button will work', () => {
|
|||||||
it('Keyboard {tab} button will work', () => {
|
it('Keyboard {tab} button will work', () => {
|
||||||
testUtil.setDOM();
|
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");
|
expect(output).toBe("test\t");
|
||||||
});
|
});
|
||||||
@ -59,11 +59,11 @@ it('Keyboard {tab} button will work', () => {
|
|||||||
it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
|
it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
tabCharOnTab: false
|
tabCharOnTab: false
|
||||||
});
|
});
|
||||||
|
|
||||||
let output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
const output = keyboard.utilities.getUpdatedInput("{tab}", "test");
|
||||||
|
|
||||||
expect(output).toBe("test");
|
expect(output).toBe("test");
|
||||||
});
|
});
|
||||||
@ -71,9 +71,9 @@ it('Keyboard {tab} button will work with tabCharOnTab:false', () => {
|
|||||||
it('Keyboard {enter} button will work', () => {
|
it('Keyboard {enter} button will work', () => {
|
||||||
testUtil.setDOM();
|
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");
|
expect(output).toBe("test");
|
||||||
});
|
});
|
||||||
@ -81,11 +81,11 @@ it('Keyboard {enter} button will work', () => {
|
|||||||
it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
|
it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
newLineOnEnter: true
|
newLineOnEnter: true
|
||||||
});
|
});
|
||||||
|
|
||||||
let output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
const output = keyboard.utilities.getUpdatedInput("{enter}", "test");
|
||||||
|
|
||||||
expect(output).toBe("test\n");
|
expect(output).toBe("test\n");
|
||||||
});
|
});
|
||||||
@ -93,10 +93,10 @@ it('Keyboard {enter} button will work with newLineOnEnter:true', () => {
|
|||||||
it('Keyboard {numpadX} buttons will work', () => {
|
it('Keyboard {numpadX} buttons will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
for(let i = 0;i<=9;i++){
|
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}`);
|
expect(output).toBe(`test${i}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -104,9 +104,9 @@ it('Keyboard {numpadX} buttons will work', () => {
|
|||||||
it('Keyboard {numpaddivide} button will work', () => {
|
it('Keyboard {numpaddivide} button will work', () => {
|
||||||
testUtil.setDOM();
|
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/");
|
expect(output).toBe("test/");
|
||||||
});
|
});
|
||||||
@ -114,9 +114,9 @@ it('Keyboard {numpaddivide} button will work', () => {
|
|||||||
it('Keyboard {numpadmultiply} button will work', () => {
|
it('Keyboard {numpadmultiply} button will work', () => {
|
||||||
testUtil.setDOM();
|
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*");
|
expect(output).toBe("test*");
|
||||||
});
|
});
|
||||||
@ -124,9 +124,9 @@ it('Keyboard {numpadmultiply} button will work', () => {
|
|||||||
it('Keyboard {numpadsubtract} button will work', () => {
|
it('Keyboard {numpadsubtract} button will work', () => {
|
||||||
testUtil.setDOM();
|
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-");
|
expect(output).toBe("test-");
|
||||||
});
|
});
|
||||||
@ -134,9 +134,9 @@ it('Keyboard {numpadsubtract} button will work', () => {
|
|||||||
it('Keyboard {numpadadd} button will work', () => {
|
it('Keyboard {numpadadd} button will work', () => {
|
||||||
testUtil.setDOM();
|
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+");
|
expect(output).toBe("test+");
|
||||||
});
|
});
|
||||||
@ -144,9 +144,9 @@ it('Keyboard {numpadadd} button will work', () => {
|
|||||||
it('Keyboard {numpadadd} button will work', () => {
|
it('Keyboard {numpadadd} button will work', () => {
|
||||||
testUtil.setDOM();
|
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+");
|
expect(output).toBe("test+");
|
||||||
});
|
});
|
||||||
@ -154,9 +154,9 @@ it('Keyboard {numpadadd} button will work', () => {
|
|||||||
it('Keyboard {numpaddecimal} button will work', () => {
|
it('Keyboard {numpaddecimal} button will work', () => {
|
||||||
testUtil.setDOM();
|
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.");
|
expect(output).toBe("test.");
|
||||||
});
|
});
|
||||||
@ -164,7 +164,7 @@ it('Keyboard {numpaddecimal} button will work', () => {
|
|||||||
it('Keyboard custom function buttons will work', () => {
|
it('Keyboard custom function buttons will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
layout: {
|
layout: {
|
||||||
default: [
|
default: [
|
||||||
"{randombuttontest}"
|
"{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(output).toBe("test");
|
||||||
expect(keyboard.getButtonElement("{randombuttontest}").onclick).toBeTruthy();
|
expect(keyboard.getButtonElement("{randombuttontest}").onclick).toBeTruthy();
|
||||||
@ -181,9 +181,9 @@ it('Keyboard custom function buttons will work', () => {
|
|||||||
it('Keyboard "{" button will work', () => {
|
it('Keyboard "{" button will work', () => {
|
||||||
testUtil.setDOM();
|
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{");
|
expect(output).toBe("test{");
|
||||||
});
|
});
|
||||||
@ -191,9 +191,9 @@ it('Keyboard "{" button will work', () => {
|
|||||||
it('Keyboard "}" button will work', () => {
|
it('Keyboard "}" button will work', () => {
|
||||||
testUtil.setDOM();
|
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}");
|
expect(output).toBe("test}");
|
||||||
});
|
});
|
||||||
@ -201,11 +201,11 @@ it('Keyboard "}" button will work', () => {
|
|||||||
it('Keyboard standard button will affect input', () => {
|
it('Keyboard standard button will affect input', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
for (let i = 65; i <= 90; i++) {
|
for (let i = 65; i <= 90; i++) {
|
||||||
let char = String.fromCharCode(i);
|
const char = String.fromCharCode(i);
|
||||||
let output = keyboard.utilities.getUpdatedInput(char, "test");
|
const output = keyboard.utilities.getUpdatedInput(char, "test");
|
||||||
expect(output).toBe(`test${char}`);
|
expect(output).toBe(`test${char}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -213,7 +213,7 @@ it('Keyboard standard button will affect input', () => {
|
|||||||
it('Keyboard updateCaretPos will work with minus', () => {
|
it('Keyboard updateCaretPos will work with minus', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
syncInstanceInputs: true
|
syncInstanceInputs: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
|
|||||||
it('Keyboard updateCaretPos will work with minus', () => {
|
it('Keyboard updateCaretPos will work with minus', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretPosition = 5;
|
keyboard.caretPosition = 5;
|
||||||
keyboard.utilities.updateCaretPos(2, true);
|
keyboard.utilities.updateCaretPos(2, true);
|
||||||
@ -237,7 +237,7 @@ it('Keyboard updateCaretPos will work with minus', () => {
|
|||||||
it('Keyboard updateCaretPos will work with plus', () => {
|
it('Keyboard updateCaretPos will work with plus', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretPosition = 5;
|
keyboard.caretPosition = 5;
|
||||||
keyboard.utilities.updateCaretPos(2);
|
keyboard.utilities.updateCaretPos(2);
|
||||||
@ -248,7 +248,7 @@ it('Keyboard updateCaretPos will work with plus', () => {
|
|||||||
it('Keyboard addStringAt will work with debug', () => {
|
it('Keyboard addStringAt will work with debug', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ it('Keyboard addStringAt will work with debug', () => {
|
|||||||
it('Keyboard addStringAt will work with position', () => {
|
it('Keyboard addStringAt will work with position', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ it('Keyboard addStringAt will work with position', () => {
|
|||||||
it('Keyboard addStringAt will respect maxLength', () => {
|
it('Keyboard addStringAt will respect maxLength', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true,
|
debug: true,
|
||||||
maxLength: 4
|
maxLength: 4
|
||||||
});
|
});
|
||||||
@ -292,13 +292,13 @@ it('Keyboard addStringAt will respect maxLength', () => {
|
|||||||
it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
|
it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "test")
|
||||||
|
|
||||||
expect(output).toBeFalsy();
|
expect(output).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -306,7 +306,7 @@ it('Keyboard handleMaxLength will exit out on same updatedInput', () => {
|
|||||||
it('Keyboard handleMaxLength will work with object maxLength', () => {
|
it('Keyboard handleMaxLength will work with object maxLength', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: {
|
maxLength: {
|
||||||
default: 4
|
default: 4
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ it('Keyboard handleMaxLength will work with object maxLength', () => {
|
|||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeTruthy();
|
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', () => {
|
it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: {
|
maxLength: {
|
||||||
default: 4
|
default: 4
|
||||||
},
|
},
|
||||||
@ -331,7 +331,7 @@ it('Keyboard handleMaxLength will work with object maxLength and debug', () => {
|
|||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeTruthy();
|
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', () => {
|
it('Keyboard handleMaxLength will return false if obj maxLength not reached', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: {
|
maxLength: {
|
||||||
default: 7
|
default: 7
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ it('Keyboard handleMaxLength will return false if obj maxLength not reached', ()
|
|||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeFalsy();
|
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', () => {
|
it('Keyboard handleMaxLength will work without debug', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: 4
|
maxLength: 4
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeTruthy();
|
expect(output).toBeTruthy();
|
||||||
});
|
});
|
||||||
@ -371,13 +371,13 @@ it('Keyboard handleMaxLength will work without debug', () => {
|
|||||||
it('Keyboard handleMaxLength will work with numeric maxLength', () => {
|
it('Keyboard handleMaxLength will work with numeric maxLength', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: 3
|
maxLength: 3
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBe(true);
|
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', () => {
|
it('Keyboard handleMaxLength wont work with non numeric or object maxLength', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: "wrong"
|
maxLength: "wrong"
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeFalsy();
|
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)', () => {
|
it('Keyboard handleMaxLength wont work with non numeric or object maxLength (with debug)', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: "wrong",
|
maxLength: "wrong",
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
|
|
||||||
let output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
const output = keyboard.utilities.handleMaxLength(keyboard.input, "testq");
|
||||||
|
|
||||||
expect(output).toBeFalsy();
|
expect(output).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -414,11 +414,11 @@ it('Keyboard handleMaxLength wont work with non numeric or object maxLength (wit
|
|||||||
it('Keyboard isMaxLengthReached will work', () => {
|
it('Keyboard isMaxLengthReached will work', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
maxLength: 5
|
maxLength: 5
|
||||||
});
|
});
|
||||||
|
|
||||||
let output = keyboard.utilities.isMaxLengthReached();
|
const output = keyboard.utilities.isMaxLengthReached();
|
||||||
|
|
||||||
expect(output).toBeFalsy();
|
expect(output).toBeFalsy();
|
||||||
});
|
});
|
||||||
@ -426,7 +426,7 @@ it('Keyboard isMaxLengthReached will work', () => {
|
|||||||
it('Keyboard removeAt will exit out on caretPosition:0', () => {
|
it('Keyboard removeAt will exit out on caretPosition:0', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.setInput("test");
|
keyboard.setInput("test");
|
||||||
keyboard.caretPosition = 0;
|
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', () => {
|
it('Keyboard removeAt will remove multi-byte unicodes with caretPos>0', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
|
|
||||||
keyboard.caretPosition = 6;
|
keyboard.caretPosition = 6;
|
||||||
let output = keyboard.utilities.removeAt("test\uD83D\uDE00", 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', () => {
|
it('Keyboard removeAt will not remove multi-byte unicodes with caretPos:0', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
let output = keyboard.utilities.removeAt("\uD83D\uDE00");
|
let output = keyboard.utilities.removeAt("\uD83D\uDE00");
|
||||||
expect(output).toBeFalsy();
|
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', () => {
|
it('Keyboard removeAt will remove regular strings', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
|
|
||||||
let keyboard = new Keyboard({
|
const keyboard = new Keyboard({
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -482,12 +482,12 @@ it('Keyboard removeAt will remove regular strings', () => {
|
|||||||
|
|
||||||
it('Keyboard will work with custom (and weird) class', () => {
|
it('Keyboard will work with custom (and weird) class', () => {
|
||||||
testUtil.setDOM("my--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");
|
expect(keyboard.keyboardDOMClass).toBe("my--weird--class");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Keyboard camelCase will work with empty strings', () => {
|
it('Keyboard camelCase will work with empty strings', () => {
|
||||||
testUtil.setDOM();
|
testUtil.setDOM();
|
||||||
let keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
expect(keyboard.utilities.camelCase()).toBeFalsy();
|
expect(keyboard.utilities.camelCase()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user