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

23 lines
763 B
TypeScript
Raw Normal View History

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, mimeSniffBytePattern, mimeSniffPatternMask } = fileType;
assertEquals(
mimeSniffBytePattern.length,
mimeSniffPatternMask.length,
`Pattern and mask for ${name} are not the same size`,
);
}
});