Test document routing for non-image extensions
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user