Skip to content

Commit

Permalink
avoid using as any casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaciras committed Oct 12, 2023
1 parent 1082837 commit 0ca8001
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { socksConnector, socksDispatcher } from "./index";

const kGlobalDispatcher = Symbol.for("undici.globalDispatcher.1");

declare const global: typeof globalThis & {
[kGlobalDispatcher]?: Dispatcher;
};

function setupHttpServer(options?: MockttpOptions) {
const server = getLocal(options);
beforeEach(() => server.start());
Expand Down Expand Up @@ -236,17 +240,17 @@ it("should set the proxy globally", async () => {
port: plainProxy.port,
});

(global as any)[kGlobalDispatcher] = dispatcher;
global[kGlobalDispatcher] = dispatcher;
try {
const inbound = await verifyFetchSuccess(httpServer, dispatcher);
expect(inbound.remotePort).toBe(plainProxy.outbound.localPort);
} finally {
delete (global as any)[kGlobalDispatcher];
delete global[kGlobalDispatcher];
}
});

it("should proxy WebSocket", async () => {
(global as any)[kGlobalDispatcher] = socksDispatcher({
global[kGlobalDispatcher] = socksDispatcher({
type: 5,
host: plainProxy.address,
port: plainProxy.port,
Expand All @@ -261,6 +265,6 @@ it("should proxy WebSocket", async () => {
expect(wsServer.inbound.remotePort).toBe(plainProxy.outbound.localPort);
} finally {
ws.close();
delete (global as any)[kGlobalDispatcher];
delete global[kGlobalDispatcher];
}
});

0 comments on commit 0ca8001

Please sign in to comment.