test(telegram): fix incomplete sticker-cache mocks in tests

This commit is contained in:
Ayaan Zaidi 2026-03-18 15:37:24 +05:30
parent b9e08a6839
commit f2655e1e92
No known key found for this signature in database
2 changed files with 10 additions and 4 deletions

View File

@ -41,6 +41,10 @@ vi.mock("../../../src/config/sessions.js", async (importOriginal) => {
vi.mock("./sticker-cache.js", () => ({
cacheSticker: vi.fn(),
getCachedSticker: () => null,
getCacheStats: () => ({ count: 0 }),
searchStickers: () => [],
getAllCachedStickers: () => [],
describeStickerImage: vi.fn(),
}));

View File

@ -28,9 +28,13 @@ vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
vi.mock("../sticker-cache.js", () => ({
cacheSticker: () => {},
getCachedSticker: () => null,
getCacheStats: () => ({ count: 0 }),
searchStickers: () => [],
getAllCachedStickers: () => [],
describeStickerImage: async () => null,
}));
let resolveMedia: typeof import("./delivery.js").resolveMedia;
import { resolveMedia } from "./delivery.js";
const MAX_MEDIA_BYTES = 10_000_000;
const BOT_TOKEN = "tok123";
@ -165,9 +169,7 @@ async function flushRetryTimers() {
}
describe("resolveMedia getFile retry", () => {
beforeEach(async () => {
vi.resetModules();
({ resolveMedia } = await import("./delivery.js"));
beforeEach(() => {
vi.useFakeTimers();
fetchRemoteMedia.mockReset();
saveMediaBuffer.mockReset();