Skip to content

Commit 0c27f0a

Browse files
committed
Fix keyboard test since Linux now also implements numpad keys
1 parent f241d00 commit 0c27f0a

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

test/keyboard.js

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,31 @@ const os = require("os");
44
// TODO: Need tests for keyToggle, typeString, typeStringDelayed, and setKeyboardDelay.
55

66
describe("Keyboard", () => {
7-
it("Tap a key.", function() {
8-
expect(() => libnut.keyTap("a")).not.toThrow();
9-
expect(() => libnut.keyTap("a", "control")).not.toThrow();
10-
expect(() => libnut.keyTap()).toThrowError(/A string was expected/);
11-
});
7+
it("Tap a key.", function () {
8+
expect(() => libnut.keyTap("a")).not.toThrow();
9+
expect(() => libnut.keyTap("a", "control")).not.toThrow();
10+
expect(() => libnut.keyTap()).toThrowError(/A string was expected/);
11+
});
1212

13-
it("Tap a key with modifier array.", function() {
14-
expect(() => libnut.keyTap("a", ["alt", "control"])).not.toThrow();
15-
});
13+
it("Tap a key with modifier array.", function () {
14+
expect(() => libnut.keyTap("a", ["alt", "control"])).not.toThrow();
15+
});
1616

17-
// This it won't fail if there's an issue, but it will help you identify an issue if ran locally.
18-
it("Tap all keys.", function() {
19-
const chars = "abcdefghijklmnopqrstuvwxyz1234567890,./;'[]\\".split("");
17+
// This it won't fail if there's an issue, but it will help you identify an issue if ran locally.
18+
it("Tap all keys.", function () {
19+
const chars = "abcdefghijklmnopqrstuvwxyz1234567890,./;'[]\\".split("");
2020

21-
for (const x in chars) {
22-
expect(() => libnut.keyTap(chars[x])).not.toThrow();
23-
}
24-
});
21+
for (const x in chars) {
22+
expect(() => libnut.keyTap(chars[x])).not.toThrow();
23+
}
24+
});
2525

26-
// This it won't fail if there's an issue, but it will help you identify an issue if ran locally.
27-
it("Tap all numpad keys.", function() {
28-
const nums = "0123456789".split("");
26+
// This it won't fail if there's an issue, but it will help you identify an issue if ran locally.
27+
it("Tap all numpad keys.", function () {
28+
const nums = "0123456789".split("");
2929

30-
for (const x in nums) {
31-
if (os.platform() === "linux") {
32-
expect(() => libnut.keyTap("numpad_" + nums[x])).toThrowError(
33-
/Invalid key code/
34-
);
35-
} else {
36-
expect(() => libnut.keyTap("numpad_" + nums[x])).not.toThrow();
37-
}
38-
}
39-
});
30+
for (const x in nums) {
31+
expect(() => libnut.keyTap("numpad_" + nums[x])).not.toThrow();
32+
}
33+
});
4034
});

0 commit comments

Comments
 (0)