Skip to content

Commit 9638564

Browse files
committed
(#40) Fixed names to use libnut instead of robotjs
1 parent d09f816 commit 9638564

8 files changed

+116
-116
lines changed

Diff for: lib/adapter/native.adapter.class.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { Button } from "../button.enum";
22
import { Key } from "../key.enum";
33
import { Point } from "../point.class";
44
import { ClipboardAction } from "../provider/native/clipboardy-clipboard-action.class";
5-
import { KeyboardAction } from "../provider/native/robotjs-keyboard-action.class";
6-
import { MouseAction } from "../provider/native/robotjs-mouse-action.class";
5+
import { KeyboardAction } from "../provider/native/libnut-keyboard-action.class";
6+
import { MouseAction } from "../provider/native/libnut-mouse-action.class";
77
import { NativeAdapter } from "./native.adapter.class";
88

99
jest.mock("../provider/native/clipboardy-clipboard-action.class");
10-
jest.mock("../provider/native/robotjs-mouse-action.class");
11-
jest.mock("../provider/native/robotjs-keyboard-action.class");
10+
jest.mock("../provider/native/libnut-mouse-action.class");
11+
jest.mock("../provider/native/libnut-keyboard-action.class");
1212

1313
describe("NativeAdapter class", () => {
1414
it("should delegate calls to setMouseDelay", async () => {

Diff for: lib/adapter/native.adapter.class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { ClipboardActionProvider } from "../provider/native/clipboard-action-pro
55
import { ClipboardAction } from "../provider/native/clipboardy-clipboard-action.class";
66
import { KeyboardActionProvider } from "../provider/native/keyboard-action-provider.interface";
77
import { MouseActionProvider } from "../provider/native/mouse-action-provider.interface";
8-
import { KeyboardAction } from "../provider/native/robotjs-keyboard-action.class";
9-
import { MouseAction } from "../provider/native/robotjs-mouse-action.class";
8+
import { KeyboardAction } from "../provider/native/libnut-keyboard-action.class";
9+
import { MouseAction } from "../provider/native/libnut-mouse-action.class";
1010

1111
/**
1212
* {@link NativeAdapter} serves as an abstraction layer for all OS level interactions.

Diff for: lib/adapter/vision.adapter.class.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Image } from "../image.class";
22
import { MatchRequest } from "../match-request.class";
3-
import { ScreenAction } from "../provider/native/robotjs-screen-action.class";
3+
import { ScreenAction } from "../provider/native/libnut-screen-action.class";
44
import { TemplateMatchingFinder } from "../provider/opencv/template-matching-finder.class";
55
import { Region } from "../region.class";
66
import { VisionAdapter } from "./vision.adapter.class";
77

88
jest.mock("../provider/opencv/template-matching-finder.class");
9-
jest.mock("../provider/native/robotjs-screen-action.class");
9+
jest.mock("../provider/native/libnut-screen-action.class");
1010

1111
describe("VisionAdapter class", () => {
1212
it("should delegate calls to grabScreen", () => {

Diff for: lib/adapter/vision.adapter.class.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Image } from "../image.class";
22
import { MatchRequest } from "../match-request.class";
33
import { MatchResult } from "../match-result.class";
4-
import { ScreenAction } from "../provider/native/robotjs-screen-action.class";
4+
import { ScreenAction } from "../provider/native/libnut-screen-action.class";
55
import { ScreenActionProvider } from "../provider/native/screen-action-provider.interface";
66
import { DataSink } from "../provider/opencv/data-sink.interface";
77
import { FinderInterface } from "../provider/opencv/finder.interface";

Diff for: lib/provider/native/robotjs-keyboard-action.class.ts renamed to lib/provider/native/libnut-keyboard-action.class.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import robot = require("@nut-tree/libnut");
1+
import libnut = require("@nut-tree/libnut");
22
import { Key } from "../../key.enum";
33
import { KeyboardActionProvider } from "./keyboard-action-provider.interface";
44

@@ -135,7 +135,7 @@ export class KeyboardAction implements KeyboardActionProvider {
135135
const nativeKey = KeyboardAction.keyLookup(key);
136136
const modifierKeys = this.mapModifierKeys(...modifiers);
137137
if (nativeKey) {
138-
robot.keyToggle(nativeKey, event, modifierKeys);
138+
libnut.keyToggle(nativeKey, event, modifierKeys);
139139
}
140140
resolve();
141141
} catch (e) {
@@ -150,7 +150,7 @@ export class KeyboardAction implements KeyboardActionProvider {
150150
public type(input: string): Promise<void> {
151151
return new Promise<void>((resolve, reject) => {
152152
try {
153-
robot.typeString(input);
153+
libnut.typeString(input);
154154
resolve();
155155
} catch (e) {
156156
reject(e);
@@ -166,7 +166,7 @@ export class KeyboardAction implements KeyboardActionProvider {
166166
const nativeKey = KeyboardAction.keyLookup(key);
167167
const modifierKeys = KeyboardAction.mapModifierKeys(...modifiers);
168168
if (nativeKey) {
169-
robot.keyTap(nativeKey, modifierKeys);
169+
libnut.keyTap(nativeKey, modifierKeys);
170170
}
171171
resolve();
172172
} catch (e) {
@@ -202,6 +202,6 @@ export class KeyboardAction implements KeyboardActionProvider {
202202
}
203203

204204
public setKeyboardDelay(delay: number): void {
205-
robot.setKeyboardDelay(delay);
205+
libnut.setKeyboardDelay(delay);
206206
}
207207
}

Diff for: lib/provider/native/robotjs-keyboard.action.class.spec.ts renamed to lib/provider/native/libnut-keyboard.action.class.spec.ts

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import robot = require("@nut-tree/libnut");
1+
import libnut = require("@nut-tree/libnut");
22
import { Key } from "../../key.enum";
3-
import { KeyboardAction } from "./robotjs-keyboard-action.class";
3+
import { KeyboardAction } from "./libnut-keyboard-action.class";
44

55
jest.mock("@nut-tree/libnut");
66

77
beforeEach(() => {
88
jest.resetAllMocks();
99
});
1010

11-
describe("robotjs keyboard action", () => {
11+
describe("libnut keyboard action", () => {
1212
describe("click", () => {
13-
it("should forward the keyTap call to robotjs for a known key", () => {
13+
it("should forward the keyTap call to libnut for a known key", () => {
1414
// GIVEN
1515
const SUT = new KeyboardAction();
1616

1717
// WHEN
1818
SUT.click(Key.A);
1919

2020
// THEN
21-
expect(robot.keyTap).toBeCalledTimes(1);
21+
expect(libnut.keyTap).toBeCalledTimes(1);
2222
});
2323

24-
it("should reject on robotjs errors", async () => {
24+
it("should reject on libnut errors", async () => {
2525
// GIVEN
2626
const SUT = new KeyboardAction();
27-
robot.keyTap = jest.fn(() => {
27+
libnut.keyTap = jest.fn(() => {
2828
throw new Error("Test error");
2929
});
3030

@@ -34,20 +34,20 @@ describe("robotjs keyboard action", () => {
3434
expect(SUT.click(Key.A)).rejects.toThrowError("Test error");
3535
});
3636

37-
it("should not forward the keyTap call to robotjs for an unknown key", () => {
37+
it("should not forward the keyTap call to libnut for an unknown key", () => {
3838
// GIVEN
3939
const SUT = new KeyboardAction();
4040

4141
// WHEN
4242
SUT.click(Key.Add);
4343

4444
// THEN
45-
expect(robot.keyTap).not.toBeCalled();
45+
expect(libnut.keyTap).not.toBeCalled();
4646
});
4747
});
4848

4949
describe("type", () => {
50-
it("should forward the type call to robotjs", () => {
50+
it("should forward the type call to libnut", () => {
5151
// GIVEN
5252
const SUT = new KeyboardAction();
5353
const payload = "testInput";
@@ -56,14 +56,14 @@ describe("robotjs keyboard action", () => {
5656
SUT.type(payload);
5757

5858
// THEN
59-
expect(robot.typeString).toBeCalledTimes(1);
60-
expect(robot.typeString).toBeCalledWith(payload);
59+
expect(libnut.typeString).toBeCalledTimes(1);
60+
expect(libnut.typeString).toBeCalledWith(payload);
6161
});
6262

63-
it("should reject on robotjs errors", async () => {
63+
it("should reject on libnut errors", async () => {
6464
// GIVEN
6565
const SUT = new KeyboardAction();
66-
robot.typeString = jest.fn(() => {
66+
libnut.typeString = jest.fn(() => {
6767
throw new Error("Test error");
6868
});
6969

@@ -75,16 +75,16 @@ describe("robotjs keyboard action", () => {
7575
});
7676

7777
describe("pressKey", () => {
78-
it("should forward the pressKey call to robotjs for a known key", () => {
78+
it("should forward the pressKey call to libnut for a known key", () => {
7979
// GIVEN
8080
const SUT = new KeyboardAction();
8181

8282
// WHEN
8383
SUT.pressKey(Key.A);
8484

8585
// THEN
86-
expect(robot.keyToggle).toBeCalledTimes(1);
87-
expect(robot.keyToggle).toBeCalledWith(KeyboardAction.keyLookup(Key.A), "down", []);
86+
expect(libnut.keyToggle).toBeCalledTimes(1);
87+
expect(libnut.keyToggle).toBeCalledWith(KeyboardAction.keyLookup(Key.A), "down", []);
8888
});
8989

9090
it("should treat a list of keys as modifiers + the actual key to press", () => {
@@ -95,26 +95,26 @@ describe("robotjs keyboard action", () => {
9595
SUT.pressKey(Key.LeftControl, Key.A);
9696

9797
// THEN
98-
expect(robot.keyToggle).toBeCalledTimes(1);
99-
expect(robot.keyToggle)
98+
expect(libnut.keyToggle).toBeCalledTimes(1);
99+
expect(libnut.keyToggle)
100100
.toBeCalledWith(KeyboardAction.keyLookup(Key.A), "down", [KeyboardAction.keyLookup(Key.LeftControl)]);
101101
});
102102

103-
it("should not forward the pressKey call to robotjs for an unknown key", () => {
103+
it("should not forward the pressKey call to libnut for an unknown key", () => {
104104
// GIVEN
105105
const SUT = new KeyboardAction();
106106

107107
// WHEN
108108
SUT.pressKey(Key.Add);
109109

110110
// THEN
111-
expect(robot.keyToggle).not.toBeCalled();
111+
expect(libnut.keyToggle).not.toBeCalled();
112112
});
113113

114-
it("should reject on robotjs errors", async () => {
114+
it("should reject on libnut errors", async () => {
115115
// GIVEN
116116
const SUT = new KeyboardAction();
117-
robot.keyToggle = jest.fn(() => {
117+
libnut.keyToggle = jest.fn(() => {
118118
throw new Error("Test error");
119119
});
120120

@@ -126,16 +126,16 @@ describe("robotjs keyboard action", () => {
126126
});
127127

128128
describe("releaseKey", () => {
129-
it("should forward the releaseKey call to robotjs for a known key", () => {
129+
it("should forward the releaseKey call to libnut for a known key", () => {
130130
// GIVEN
131131
const SUT = new KeyboardAction();
132132

133133
// WHEN
134134
SUT.releaseKey(Key.A);
135135

136136
// THEN
137-
expect(robot.keyToggle).toBeCalledTimes(1);
138-
expect(robot.keyToggle).toBeCalledWith(KeyboardAction.keyLookup(Key.A), "up", []);
137+
expect(libnut.keyToggle).toBeCalledTimes(1);
138+
expect(libnut.keyToggle).toBeCalledWith(KeyboardAction.keyLookup(Key.A), "up", []);
139139
});
140140

141141
it("should treat a list of keys as modifiers + the actual key to release", () => {
@@ -146,26 +146,26 @@ describe("robotjs keyboard action", () => {
146146
SUT.releaseKey(Key.LeftControl, Key.A);
147147

148148
// THEN
149-
expect(robot.keyToggle).toBeCalledTimes(1);
150-
expect(robot.keyToggle)
149+
expect(libnut.keyToggle).toBeCalledTimes(1);
150+
expect(libnut.keyToggle)
151151
.toBeCalledWith(KeyboardAction.keyLookup(Key.A), "up", [KeyboardAction.keyLookup(Key.LeftControl)]);
152152
});
153153

154-
it("should not forward the releaseKey call to robotjs for an unknown key", () => {
154+
it("should not forward the releaseKey call to libnut for an unknown key", () => {
155155
// GIVEN
156156
const SUT = new KeyboardAction();
157157

158158
// WHEN
159159
SUT.releaseKey(Key.Add);
160160

161161
// THEN
162-
expect(robot.keyToggle).not.toBeCalled();
162+
expect(libnut.keyToggle).not.toBeCalled();
163163
});
164164

165-
it("should reject on robotjs errors", async () => {
165+
it("should reject on libnut errors", async () => {
166166
// GIVEN
167167
const SUT = new KeyboardAction();
168-
robot.keyToggle = jest.fn(() => {
168+
libnut.keyToggle = jest.fn(() => {
169169
throw new Error("Test error");
170170
});
171171

0 commit comments

Comments
 (0)