mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-20 01:22:59 +08:00
Tests update
This commit is contained in:
parent
70b99b44c6
commit
f2a97b6dcb
67
src/demo/tests/MultipleKeyboardsDestroyDemo.test.js
Normal file
67
src/demo/tests/MultipleKeyboardsDestroyDemo.test.js
Normal file
@ -0,0 +1,67 @@
|
||||
import TestUtility from '../../utils/TestUtility';
|
||||
import MultipleKeyboardsDestroyDemo from '../MultipleKeyboardsDestroyDemo';
|
||||
|
||||
let testUtil = new TestUtility();
|
||||
|
||||
it('Demo will load', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
});
|
||||
|
||||
it('Demo onDOMLoaded will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
expect(demo.keyboard).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.onChange("test");
|
||||
demo.keyboard2.getButtonElement("q").click();
|
||||
|
||||
expect(document.body.querySelector('.input').value).toBe("test");
|
||||
expect(document.body.querySelector('.input2').value).toBe("q");
|
||||
});
|
||||
|
||||
it('Demo onChange will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("q").onclick();
|
||||
|
||||
expect(document.body.querySelector('.input').value).toBe("q");
|
||||
});
|
||||
|
||||
it('Demo input change will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
document.body.querySelector('.input').value = "test";
|
||||
document.body.querySelector('.input').dispatchEvent(new Event('input'));
|
||||
|
||||
document.body.querySelector('.input2').value = "test2";
|
||||
document.body.querySelector('.input2').dispatchEvent(new Event('input'));
|
||||
|
||||
expect(demo.keyboard.getInput()).toBe("test");
|
||||
expect(demo.keyboard2.getInput()).toBe("test2");
|
||||
});
|
||||
|
||||
it('Demo handleShiftButton will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let demo = new MultipleKeyboardsDestroyDemo();
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("shift");
|
||||
|
||||
demo.keyboard.getButtonElement("{shift}")[0].onclick();
|
||||
expect(demo.keyboard.options.layoutName).toBe("default");
|
||||
});
|
@ -1228,10 +1228,16 @@ it('Keyboard destroy will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
|
||||
keyboard.destroy();
|
||||
expect(keyboard.keyboardDOM).toBe(null);
|
||||
});
|
||||
|
||||
expect(keyboard.keyboardDOM.innerHTML).toBeFalsy();
|
||||
it('Keyboard destroy will work with debug option', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({ debug: true });
|
||||
keyboard.destroy();
|
||||
expect(keyboard.keyboardDOM).toBe(null);
|
||||
});
|
||||
|
||||
it('Keyboard disableButtonHold will work', () => {
|
||||
@ -1325,4 +1331,10 @@ it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Keyboard recurseButtons will not work without a valid param', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard();
|
||||
expect(keyboard.recurseButtons()).toBe(false);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user