Skip to content

Commit d158da6

Browse files
committed
(#310) Migrate window.function to not use adapters
1 parent 5e14945 commit d158da6

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/window.function.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {createWindowApi} from "./window.function";
2-
import {NativeAdapter} from "./adapter/native.adapter.class";
32
import {Window} from "./window.class";
43
import providerRegistry from "./provider/provider-registry.class";
54

@@ -9,7 +8,7 @@ describe("WindowApi", () => {
98
describe("getWindows", () => {
109
it("should return a list of open Windows", async () => {
1110
// GIVEN
12-
const SUT = createWindowApi(new NativeAdapter(providerRegistry));
11+
const SUT = createWindowApi(providerRegistry);
1312

1413
// WHEN
1514
const windows = await SUT.getWindows()
@@ -24,7 +23,7 @@ describe("WindowApi", () => {
2423
describe("getActiveWindow", () => {
2524
it("should return the a single Window which is currently active", async () => {
2625
// GIVEN
27-
const SUT = createWindowApi(new NativeAdapter(providerRegistry));
26+
const SUT = createWindowApi(providerRegistry);
2827

2928
// WHEN
3029
const window = await SUT.getActiveWindow();

lib/window.function.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { WindowApi } from "./window-api.interface";
2-
import { NativeAdapter } from "./adapter/native.adapter.class";
32
import { Window } from "./window.class";
3+
import {ProviderRegistry} from "./provider/provider-registry.class";
44

5-
export const createWindowApi = (nativeAdapter: NativeAdapter): WindowApi => {
5+
export const createWindowApi = (providerRegistry: ProviderRegistry): WindowApi => {
66
return ({
77
async getActiveWindow(): Promise<Window> {
8-
const windowHandle = await nativeAdapter.getActiveWindow();
9-
return new Window(nativeAdapter, windowHandle);
8+
const windowHandle = await providerRegistry.getWindow().getActiveWindow();
9+
return new Window(providerRegistry, windowHandle);
1010
},
1111
async getWindows(): Promise<Window[]> {
12-
const windowHandles = await nativeAdapter.getWindows();
12+
const windowHandles = await providerRegistry.getWindow().getWindows();
1313
return windowHandles.map((handle: number) => {
14-
return new Window(nativeAdapter, handle);
14+
return new Window(providerRegistry, handle);
1515
});
1616
},
1717
});

0 commit comments

Comments
 (0)