test(telegram): use lightweight clears in media handler setup

This commit is contained in:
Peter Steinberger
2026-02-22 08:00:29 +00:00
parent 9a0830bc7c
commit d559f226b3

View File

@@ -32,9 +32,9 @@ async function createBotHandlerWithOptions(options: {
replySpy: ReturnType<typeof vi.fn>; replySpy: ReturnType<typeof vi.fn>;
runtimeError: ReturnType<typeof vi.fn>; runtimeError: ReturnType<typeof vi.fn>;
}> { }> {
onSpy.mockReset(); onSpy.mockClear();
replySpy.mockReset(); replySpy.mockClear();
sendChatActionSpy.mockReset(); sendChatActionSpy.mockClear();
const runtimeError = options.runtimeError ?? vi.fn(); const runtimeError = options.runtimeError ?? vi.fn();
const runtimeLog = options.runtimeLog ?? vi.fn(); const runtimeLog = options.runtimeLog ?? vi.fn();
@@ -89,7 +89,7 @@ beforeEach(() => {
}); });
afterEach(() => { afterEach(() => {
lookupMock.mockReset(); lookupMock.mockClear();
resolvePinnedHostnameSpy?.mockRestore(); resolvePinnedHostnameSpy?.mockRestore();
resolvePinnedHostnameSpy = null; resolvePinnedHostnameSpy = null;
}); });
@@ -525,8 +525,8 @@ describe("telegram text fragments", () => {
it( it(
"buffers near-limit text and processes sequential parts as one message", "buffers near-limit text and processes sequential parts as one message",
async () => { async () => {
onSpy.mockReset(); onSpy.mockClear();
replySpy.mockReset(); replySpy.mockClear();
createTelegramBot({ token: "tok", testTimings: TELEGRAM_TEST_TIMINGS }); createTelegramBot({ token: "tok", testTimings: TELEGRAM_TEST_TIMINGS });
const handler = onSpy.mock.calls.find((call) => call[0] === "message")?.[1] as ( const handler = onSpy.mock.calls.find((call) => call[0] === "message")?.[1] as (