mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test(discord): dedupe gateway proxy runtime fixture
This commit is contained in:
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user