mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 02:27:26 +00:00
test(discord): dedupe gateway proxy runtime fixture
This commit is contained in:
@@ -70,6 +70,16 @@ vi.mock("ws", () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe("createDiscordGatewayPlugin", () => {
|
describe("createDiscordGatewayPlugin", () => {
|
||||||
|
function createRuntime() {
|
||||||
|
return {
|
||||||
|
log: vi.fn(),
|
||||||
|
error: vi.fn(),
|
||||||
|
exit: vi.fn(() => {
|
||||||
|
throw new Error("exit");
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
proxyAgentSpy.mockReset();
|
proxyAgentSpy.mockReset();
|
||||||
webSocketSpy.mockReset();
|
webSocketSpy.mockReset();
|
||||||
@@ -78,14 +88,7 @@ describe("createDiscordGatewayPlugin", () => {
|
|||||||
|
|
||||||
it("uses proxy agent for gateway WebSocket when configured", async () => {
|
it("uses proxy agent for gateway WebSocket when configured", async () => {
|
||||||
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
|
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
|
||||||
|
const runtime = createRuntime();
|
||||||
const runtime = {
|
|
||||||
log: vi.fn(),
|
|
||||||
error: vi.fn(),
|
|
||||||
exit: vi.fn(() => {
|
|
||||||
throw new Error("exit");
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
const plugin = createDiscordGatewayPlugin({
|
const plugin = createDiscordGatewayPlugin({
|
||||||
discordConfig: { proxy: "http://proxy.test:8080" },
|
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 () => {
|
it("falls back to the default gateway plugin when proxy is invalid", async () => {
|
||||||
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
|
const { createDiscordGatewayPlugin } = await import("./gateway-plugin.js");
|
||||||
|
const runtime = createRuntime();
|
||||||
const runtime = {
|
|
||||||
log: vi.fn(),
|
|
||||||
error: vi.fn(),
|
|
||||||
exit: vi.fn(() => {
|
|
||||||
throw new Error("exit");
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
const plugin = createDiscordGatewayPlugin({
|
const plugin = createDiscordGatewayPlugin({
|
||||||
discordConfig: { proxy: "bad-proxy" },
|
discordConfig: { proxy: "bad-proxy" },
|
||||||
|
|||||||
Reference in New Issue
Block a user