formats.exposed/test/index/constants.test.ts

25 lines
778 B
TypeScript

import { assertEquals } from "assert";
import { SUPPORTED_FILE_TYPES } from "../../public/index/constants.js";
Deno.test("no duplicate extensions in supported file types", () => {
const allExtensions = SUPPORTED_FILE_TYPES.flatMap((t) => t.extensions);
assertEquals(
allExtensions.length,
new Set(allExtensions).size,
"Duplicate extensions found in SUPPORTED_FILE_TYPES",
);
});
Deno.test("MIME sniffing patterns are the same size as their masks", () => {
for (const fileType of SUPPORTED_FILE_TYPES) {
const { name, mimeSniffPatterns } = fileType;
for (const { bytes, mask } of mimeSniffPatterns) {
assertEquals(
bytes.length,
mask.length,
`Pattern and mask for ${name} are not the same size`,
);
}
}
});