Skip to content
Source
Sign inSign up

image.test.ts

20 lines743 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { imageMimeType, isSvgAttachment } from "./image.ts";
4​
5describe("isSvgAttachment", () => {
6 it("recognizes SVG previews without promoting them to provider images", () => {
7 for (const mimeType of [
8 "image/svg+xml",
9 "IMAGE/SVG+XML; charset=utf-8",
10 "",
11 "application/octet-stream",
12 ]) {
13 const attachment = { name: "diagram.SVG", mimeType };
14 expect(isSvgAttachment(attachment)).toBe(true);
15 expect(imageMimeType(attachment)).toBeNull();
16 }
17 expect(isSvgAttachment({ name: "diagram.svg", mimeType: "application/pdf" })).toBe(false);
18 expect(isSvgAttachment({ name: "photo.png", mimeType: "image/png" })).toBe(false);
19 });
20});