0
我需要按下按鍵時觸發的單元測試功能。如何在茉莉花中模擬按鍵單元測試
public onKeyDown(event: KeyboardEvent): void {
if (event.ctrlKey && event.keyCode === 38) {
console.log('increase');
}
if (event.ctrlKey && event.keyCode === 40) {
console.log('decrease');
}
/* Prevent entering characters */
if (event.keyCode >= 65 && event.keyCode <= 90) {
return;
}
}
如何模擬按鍵來滿足第一個條件,例如?
http://stackoverflow.com/questions/961532/firing-a-keyboard-event-in-javascript – Randy