Skip to content

Commit 3e2f2a9

Browse files
committed
(#5) Added test for window class
1 parent d8cc180 commit 3e2f2a9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lib/window.class.spec.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {Window} from "./window.class";
2+
import {NativeAdapter} from "./adapter/native.adapter.class";
3+
4+
jest.mock("./adapter/native.adapter.class");
5+
6+
describe("Window class", () => {
7+
it("should retrieve the window region via its native adapter", async () => {
8+
// GIVEN
9+
const nativeAdapterMock = new NativeAdapter();
10+
const mockWindowHandle = 123;
11+
const SUT = new Window(nativeAdapterMock, mockWindowHandle);
12+
13+
// WHEN
14+
await SUT.region
15+
16+
// THEN
17+
expect(nativeAdapterMock.getWindowRegion).toBeCalledTimes(1);
18+
expect(nativeAdapterMock.getWindowRegion).toBeCalledWith(mockWindowHandle);
19+
});
20+
21+
it("should retrieve the window title via its native adapter", async () => {
22+
// GIVEN
23+
const nativeAdapterMock = new NativeAdapter();
24+
const mockWindowHandle = 123;
25+
const SUT = new Window(nativeAdapterMock, mockWindowHandle);
26+
27+
// WHEN
28+
await SUT.title
29+
30+
// THEN
31+
expect(nativeAdapterMock.getWindowTitle).toBeCalledTimes(1);
32+
expect(nativeAdapterMock.getWindowTitle).toBeCalledWith(mockWindowHandle);
33+
});
34+
});

0 commit comments

Comments
 (0)