mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:00:43 +00:00
test(telegram): cover handler error boundary
This commit is contained in:
@@ -179,6 +179,22 @@ describe("createTelegramBot", () => {
|
||||
expect(throttlerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(useSpy).toHaveBeenCalledWith("throttler");
|
||||
});
|
||||
|
||||
it("logs middleware errors through grammY catch without rethrowing", () => {
|
||||
const runtime = {
|
||||
error: vi.fn(),
|
||||
} as unknown as NonNullable<TelegramBotOptions["runtime"]>;
|
||||
const bot = createTelegramBot({ token: "tok", runtime });
|
||||
const catchMock = bot.catch as unknown as {
|
||||
mock: { calls: Array<[(err: unknown) => void]> };
|
||||
};
|
||||
const errorHandler = catchMock.mock.calls[0]?.[0];
|
||||
|
||||
expect(errorHandler).toBeTypeOf("function");
|
||||
expect(() => errorHandler?.(new Error("handler boom"))).not.toThrow();
|
||||
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("telegram bot error:"));
|
||||
});
|
||||
|
||||
it("uses wrapped fetch when global fetch is available", () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
const fetchSpy = vi.fn() as unknown as typeof fetch;
|
||||
|
||||
Reference in New Issue
Block a user