Update types, tests

This commit is contained in:
Francisco Hodge
2021-03-16 00:40:23 -04:00
parent 8ba81892fe
commit cae07749f4
33 changed files with 1392 additions and 957 deletions
+27 -6
View File
@@ -31,17 +31,26 @@ class Utilities {
Utilities.bindMethods(Utilities, this);
}
/**
* Retrieve button type
*
* @param {string} button The button's layout name
* @return {string} The button type
*/
getButtonType(button: string): string {
return button.includes("{") && button.includes("}") && button !== "{//}"
? "functionBtn"
: "standardBtn";
}
/**
* Adds default classes to a given button
*
* @param {string} button The button's layout name
* @return {string} The classes to be added to the button
*/
getButtonClass(button: string) {
const buttonTypeClass =
button.includes("{") && button.includes("}") && button !== "{//}"
? "functionBtn"
: "standardBtn";
getButtonClass(button: string): string {
const buttonTypeClass = this.getButtonType(button);
const buttonWithoutBraces = button.replace("{", "").replace("}", "");
let buttonNormalized = "";
@@ -418,7 +427,7 @@ class Utilities {
* Determines whether pointer events are supported
*/
pointerEventsSupported() {
return window.PointerEvent;
return !!window.PointerEvent;
}
/**
@@ -453,6 +462,18 @@ class Utilities {
);
}
/**
* Split array into chunks
*/
chunkArray<T>(arr: T[], size: number): T[][] {
return [...Array(Math.ceil(arr.length / size))].map((_, i) =>
arr.slice(size * i, size + size * i)
);
}
/**
* Reusable empty function
*/
static noop = () => {};
}
+3 -3
View File
@@ -17,11 +17,11 @@ it('Keyboard mergeDisplay will work', () => {
it('Keyboard function buttons will work', () => {
setDOM();
new Keyboard();
const keyboard = new Keyboard();
testLayoutFctButtons((fctBtnCount, fctBtnHasOnclickCount) => {
testLayoutFctButtons(keyboard, (fctBtnCount, fctBtnHasOnclickCount) => {
expect(fctBtnCount).toBe(fctBtnHasOnclickCount);
});
}, keyboard);
});
it('Keyboard {bksp} button will work', () => {