From f139a107f24f30e691cc366d6925b337e08a49cf Mon Sep 17 00:00:00 2001 From: Xiangzhe Date: Thu, 13 Aug 2026 16:41:55 -0300 Subject: [PATCH] test(bridge): height-dominant long-edge coverage Add a 100x4096 PNG case to image-normalize.test.ts alongside the existing width-dominant one, so normalizeImageBuffer's long-edge cap is proven on both axes. --- tests/unit/image-normalize.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/image-normalize.test.ts b/tests/unit/image-normalize.test.ts index 581339fd92..6620b3ff0e 100644 --- a/tests/unit/image-normalize.test.ts +++ b/tests/unit/image-normalize.test.ts @@ -31,3 +31,22 @@ test("downscales a large PNG to the long-edge cap when sharp is available", asyn const meta = await sharp(out.buffer).metadata(); assert.equal(meta.width, 2048); }); + +test("downscales a height-dominant PNG to the long-edge cap on the height axis", async (t) => { + let sharp: typeof import("sharp"); + try { + sharp = (await import("sharp")).default as never; + } catch { + t.skip("sharp not installed"); + return; + } + const tall = await sharp({ + create: { width: 100, height: 4096, channels: 3, background: "#fff" }, + }) + .png() + .toBuffer(); + const out = await normalizeImageBuffer(tall, { maxLongEdge: 2048 }); + assert.equal(out.resized, true); + const meta = await sharp(out.buffer).metadata(); + assert.equal(meta.height, 2048); +});