mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:28:26 +00:00
test: stabilize infra tests
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { startTelegramWebhook } from "./webhook.js";
|
||||
|
||||
const handlerSpy = vi.fn(
|
||||
(_req: unknown, res: { writeHead: (status: number) => void; end: (body?: string) => void }) => {
|
||||
res.writeHead(200);
|
||||
res.end("ok");
|
||||
},
|
||||
const handlerSpy = vi.hoisted(() =>
|
||||
vi.fn(
|
||||
(_req: unknown, res: { writeHead: (status: number) => void; end: (body?: string) => void }) => {
|
||||
res.writeHead(200);
|
||||
res.end("ok");
|
||||
},
|
||||
),
|
||||
);
|
||||
const setWebhookSpy = vi.hoisted(() => vi.fn());
|
||||
const stopSpy = vi.hoisted(() => vi.fn());
|
||||
const webhookCallbackSpy = vi.hoisted(() => vi.fn(() => handlerSpy));
|
||||
const createTelegramBotSpy = vi.hoisted(() =>
|
||||
vi.fn(() => ({
|
||||
api: { setWebhook: setWebhookSpy },
|
||||
stop: stopSpy,
|
||||
})),
|
||||
);
|
||||
const setWebhookSpy = vi.fn();
|
||||
const stopSpy = vi.fn();
|
||||
const webhookCallbackSpy = vi.fn(() => handlerSpy);
|
||||
|
||||
const createTelegramBotSpy = vi.fn(() => ({
|
||||
api: { setWebhook: setWebhookSpy },
|
||||
stop: stopSpy,
|
||||
}));
|
||||
|
||||
vi.mock("grammy", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("grammy")>();
|
||||
|
||||
Reference in New Issue
Block a user