Test document routing for non-image extensions

This commit is contained in:
EugeneTes
2026-09-08 12:15:46 +00:00
parent a6612edc1d
commit 40cb4a8061

View File

@@ -50,4 +50,16 @@ describe("send tool", () => {
expect(other).toEqual({ caption: "hi" });
expect(bot.sendDocument).not.toHaveBeenCalled();
});
it("sends a document when kind is auto and the extension is not an image", async () => {
await writeFile(path.join(dir, "report.pdf"), Buffer.from("%PDF-1.4"));
const text = await handleSend({ path: "report.pdf" }, opts);
expect(text).toBe("Sent report.pdf as document.");
expect(bot.sendDocument).toHaveBeenCalledTimes(1);
const [chatId, inputFile, other] = bot.sendDocument.mock.calls[0];
expect(chatId).toBe(42);
expect(inputFile).toBeInstanceOf(InputFile);
expect(other).toBeUndefined();
expect(bot.sendPhoto).not.toHaveBeenCalled();
});
});