mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-03-16 08:21:07 +08:00
feat: Trigger beforeInputUpdate when handleButtonClicked is called
This commit is contained in:
parent
9f917fea47
commit
ea35f102e7
@ -465,6 +465,13 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
if (!this.input[inputName]) this.input[inputName] = "";
|
if (!this.input[inputName]) this.input[inputName] = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform an action before any input change
|
||||||
|
*/
|
||||||
|
if (typeof this.options.beforeInputUpdate === "function") {
|
||||||
|
this.options.beforeInputUpdate(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculating new input
|
* Calculating new input
|
||||||
*/
|
*/
|
||||||
|
@ -218,6 +218,19 @@ it('Keyboard onChange will work', () => {
|
|||||||
expect(output).toBe("q");
|
expect(output).toBe("q");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Keyboard beforeInputChange will work', () => {
|
||||||
|
const mockBeforeInputUpdate = jest.fn();
|
||||||
|
|
||||||
|
const keyboard = new Keyboard({
|
||||||
|
beforeInputUpdate: mockBeforeInputUpdate,
|
||||||
|
useMouseEvents: true
|
||||||
|
});
|
||||||
|
|
||||||
|
keyboard.getButtonElement("q").onclick();
|
||||||
|
|
||||||
|
expect(mockBeforeInputUpdate).toHaveBeenCalledWith(keyboard);
|
||||||
|
});
|
||||||
|
|
||||||
it('Keyboard onChangeAll will work', () => {
|
it('Keyboard onChangeAll will work', () => {
|
||||||
let output;
|
let output;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user