mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-05-19 00:00:07 +08:00
Bump Jest version
This commit is contained in:
@@ -216,7 +216,7 @@ it('CandidateBox select candidate will work', () => {
|
||||
keyboard.getButtonElement("a").click();
|
||||
keyboard.candidateBox.candidateBoxElement.querySelector("li").click();
|
||||
|
||||
expect(onSelect).toBeCalledWith("1", expect.anything());
|
||||
expect(onSelect).toHaveBeenCalledWith("1", expect.anything());
|
||||
keyboard.destroy();
|
||||
});
|
||||
|
||||
@@ -371,41 +371,6 @@ it('CandidateBox selection should trigger onChange', () => {
|
||||
keyboard.destroy();
|
||||
});
|
||||
|
||||
it('CandidateBox selection should trigger beforeInputChange', () => {
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
default: [
|
||||
"a b {bksp}"
|
||||
]
|
||||
},
|
||||
layoutCandidates: {
|
||||
a: "1 2 3 4 5 6"
|
||||
},
|
||||
beforeInputUpdate: jest.fn(),
|
||||
});
|
||||
|
||||
let candidateBoxOnItemSelected;
|
||||
|
||||
const onSelect = jest.fn().mockImplementation((selectedCandidate) => {
|
||||
candidateBoxOnItemSelected(selectedCandidate);
|
||||
keyboard.candidateBox.destroy();
|
||||
});
|
||||
|
||||
const candidateBoxRenderFn = keyboard.candidateBox.renderPage;
|
||||
|
||||
jest.spyOn(keyboard.candidateBox, "renderPage").mockImplementation((params) => {
|
||||
candidateBoxOnItemSelected = params.onItemSelected;
|
||||
params.onItemSelected = onSelect;
|
||||
candidateBoxRenderFn(params);
|
||||
});
|
||||
|
||||
keyboard.getButtonElement("a").click();
|
||||
keyboard.candidateBox.candidateBoxElement.querySelector("li").click();
|
||||
|
||||
expect(keyboard.options.beforeInputUpdate.mock.calls[0][0]).toMatchObject(keyboard);
|
||||
keyboard.destroy();
|
||||
});
|
||||
|
||||
it('CandidateBox normalization will work', () => {
|
||||
const keyboard = new Keyboard({
|
||||
layout: {
|
||||
|
||||
@@ -212,7 +212,7 @@ it('PhysicalKeyboard keyCodeToKey will work', () => {
|
||||
|
||||
expect(keyboard.physicalKeyboard.keyCodeToKey(186)).toBe(";");
|
||||
|
||||
const methodTest = spyOn(keyboard.physicalKeyboard, "keyCodeToKey");
|
||||
const methodTest = jest.spyOn(keyboard.physicalKeyboard, "keyCodeToKey");
|
||||
|
||||
document.dispatchEvent(new KeyboardEvent('keyup', {
|
||||
keyCode: 186,
|
||||
@@ -221,5 +221,5 @@ it('PhysicalKeyboard keyCodeToKey will work', () => {
|
||||
}
|
||||
}));
|
||||
|
||||
expect(methodTest).toBeCalledWith(186);
|
||||
expect(methodTest).toHaveBeenCalledWith(186);
|
||||
});
|
||||
Reference in New Issue
Block a user