test: deepen integration tests for 11 medium tools (HEIC, large file, batch, edge cases)

This commit is contained in:
SnapOtter
2026-05-01 02:48:35 +08:00
parent 710b580cee
commit b663a1fbab
11 changed files with 549 additions and 0 deletions
+53
View File
@@ -627,6 +627,59 @@ describe("favicon", () => {
expect(manifest.name).toBe("my.app.logo");
});
// ── Animated GIF input ────────────────────────────────────────────
it("generates favicons from animated GIF input", async () => {
const GIF = readFileSync(join(FIXTURES, "animated.gif"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "anim.gif", contentType: "image/gif", content: GIF },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/favicon",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const zip = new AdmZip(Buffer.from(res.rawPayload));
const entries = zip.getEntries().map((e) => e.entryName);
expect(entries).toContain("favicon-16x16.png");
expect(entries).toContain("favicon.ico");
});
// ── Batch: 5+ images ────────────────────────────────────────────
it("generates favicons for 5 images in subfolders", async () => {
const JPG = readFileSync(join(FIXTURES, "test-100x100.jpg"));
const WEBP = readFileSync(join(FIXTURES, "test-50x50.webp"));
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
const { body, contentType } = createMultipartPayload([
{ name: "file", filename: "a.png", contentType: "image/png", content: PNG },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", content: JPG },
{ name: "file", filename: "c.webp", contentType: "image/webp", content: WEBP },
{ name: "file", filename: "d.png", contentType: "image/png", content: TINY },
{ name: "file", filename: "e.png", contentType: "image/png", content: PNG },
]);
const res = await app.inject({
method: "POST",
url: "/api/v1/tools/favicon",
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
body,
});
expect(res.statusCode).toBe(200);
const zip = new AdmZip(Buffer.from(res.rawPayload));
const entries = zip.getEntries().map((e) => e.entryName);
expect(entries.some((e) => e.startsWith("a/"))).toBe(true);
expect(entries.some((e) => e.startsWith("b/"))).toBe(true);
expect(entries.some((e) => e.startsWith("c/"))).toBe(true);
expect(entries.some((e) => e.startsWith("d/"))).toBe(true);
expect(entries.some((e) => e.startsWith("e/"))).toBe(true);
});
// ── HEIF format input ────────────────────────────────────────────
it("generates favicons from HEIF input", async () => {