Test oversize photo/document rejection
This commit is contained in:
@@ -75,4 +75,28 @@ describe("send tool", () => {
|
||||
expect(bot.sendPhoto).toHaveBeenCalledTimes(1);
|
||||
expect(bot.sendDocument).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("rejects photos over 10 MB", async () => {
|
||||
const { open } = await import("node:fs/promises");
|
||||
const fh = await open(path.join(dir, "big.png"), "w");
|
||||
try {
|
||||
await fh.truncate(11 * 1024 * 1024);
|
||||
} finally {
|
||||
await fh.close();
|
||||
}
|
||||
await expect(handleSend({ path: "big.png" }, opts)).rejects.toThrow(/photo too large: 11\.0 MB > 10 MB/);
|
||||
expect(bot.sendPhoto).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects documents over 50 MB", async () => {
|
||||
const { open } = await import("node:fs/promises");
|
||||
const fh = await open(path.join(dir, "big.bin"), "w");
|
||||
try {
|
||||
await fh.truncate(51 * 1024 * 1024);
|
||||
} finally {
|
||||
await fh.close();
|
||||
}
|
||||
await expect(handleSend({ path: "big.bin" }, opts)).rejects.toThrow(/document too large: 51\.0 MB > 50 MB/);
|
||||
expect(bot.sendDocument).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user