mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 08:32:57 +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] = "";
|
||||
|
||||
/**
|
||||
* Perform an action before any input change
|
||||
*/
|
||||
if (typeof this.options.beforeInputUpdate === "function") {
|
||||
this.options.beforeInputUpdate(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculating new input
|
||||
*/
|
||||
|
@ -218,6 +218,19 @@ it('Keyboard onChange will work', () => {
|
||||
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', () => {
|
||||
let output;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user