test(discord): dedupe gateway proxy runtime fixture

This commit is contained in:
Peter Steinberger
2026-02-19 07:32:57 +00:00
parent 5556675aae
commit 4c68a09f08

View File

@@ -70,6 +70,16 @@ vi.mock("ws", () => ({
}));
describe("createDiscordGatewayPlugin", () => {
function createRuntime() {
return {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(() => {
throw new Error("exit");
}),
};
}
beforeEach(() => {
proxyAgentSpy.mockReset();
webSocketSpy.mockReset();
@@ -78,14 +88,7 @@ describe("createDiscordGatewayPlugin", () => {
it("uses proxy agent for gateway WebSocket when configured", async () => {
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
const runtime = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(() => {
throw new Error("exit");
}),
};
const runtime = createRuntime();
const plugin = createDiscordGatewayPlugin({
discordConfig: { proxy: "http://proxy.test:8080" },
@@ -109,14 +112,7 @@ describe("createDiscordGatewayPlugin", () => {
it("falls back to the default gateway plugin when proxy is invalid", async () => {
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
const runtime = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn(() => {
throw new Error("exit");
}),
};
const runtime = createRuntime();
const plugin = createDiscordGatewayPlugin({
discordConfig: { proxy: "bad-proxy" },