Skip to content

Commit a738e19

Browse files
committed
(#5) Renamed public functions and added tests for window api functions
1 parent dc9cb4a commit a738e19

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const screen = new Screen(screenActions);
3333
const assert = new Assert(screen);
3434

3535
const {straightTo, up, down, left, right} = createMovementApi(nativeActions, lineHelper);
36-
const {windows, activeWindow } = createWindowApi(nativeActions);
36+
const {getWindows, getActiveWindow } = createWindowApi(nativeActions);
3737

3838
export {
3939
clipboard,
@@ -46,6 +46,6 @@ export {
4646
down,
4747
left,
4848
right,
49-
windows,
50-
activeWindow,
49+
getWindows,
50+
getActiveWindow,
5151
};

lib/window-api.interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
import { Window } from "./window.class";
55

66
export interface WindowApi {
7-
windows(): Promise<Window[]>;
8-
activeWindow(): Promise<Window>;
7+
getWindows(): Promise<Window[]>;
8+
getActiveWindow(): Promise<Window>;
99
}

lib/window.function.spec.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {createWindowApi} from "./window.function";
2+
import {NativeAdapter} from "./adapter/native.adapter.class";
3+
import {Window} from "./window.class";
4+
5+
describe("WindowApi", () => {
6+
describe("getWindows", () => {
7+
it("should return a list of open Windows", async () => {
8+
// GIVEN
9+
const SUT = createWindowApi(new NativeAdapter());
10+
11+
// WHEN
12+
const windows = await SUT.getWindows()
13+
14+
// THEN
15+
windows.forEach(wnd => {
16+
expect(wnd).toEqual(expect.any(Window));
17+
});
18+
});
19+
});
20+
21+
describe("getActiveWindow", () => {
22+
it("should return the a single Window which is currently active", async () => {
23+
// GIVEN
24+
const SUT = createWindowApi(new NativeAdapter());
25+
26+
// WHEN
27+
const window = await SUT.getActiveWindow();
28+
29+
// THEN
30+
expect(window).toEqual(expect.any(Window));
31+
});
32+
});
33+
});

lib/window.function.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { Window } from "./window.class";
44

55
export const createWindowApi = (nativeAdapter: NativeAdapter): WindowApi => {
66
return ({
7-
async activeWindow(): Promise<Window> {
7+
async getActiveWindow(): Promise<Window> {
88
const windowHandle = await nativeAdapter.getActiveWindow();
99
return new Window(nativeAdapter, windowHandle);
1010
},
11-
async windows(): Promise<Window[]> {
11+
async getWindows(): Promise<Window[]> {
1212
const windowHandles = await nativeAdapter.getWindows();
1313
return windowHandles.map((handle: number) => {
1414
return new Window(nativeAdapter, handle);

0 commit comments

Comments
 (0)