mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
updated examples: astro, nextjs, remix, bun, node
This commit is contained in:
37
app/__test__/media/mime-types.spec.ts
Normal file
37
app/__test__/media/mime-types.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import * as large from "../../src/media/storage/mime-types";
|
||||
import * as tiny from "../../src/media/storage/mime-types-tiny";
|
||||
|
||||
describe("media/mime-types", () => {
|
||||
test("tiny resolves", () => {
|
||||
const tests = [[".mp4", "video/mp4", ".jpg", "image/jpeg", ".zip", "application/zip"]];
|
||||
|
||||
for (const [ext, mime] of tests) {
|
||||
expect(tiny.guess(ext)).toBe(mime);
|
||||
}
|
||||
});
|
||||
|
||||
test("all tiny resolves to large", () => {
|
||||
for (const [ext, mime] of Object.entries(tiny.M)) {
|
||||
expect(large.guessMimeType("." + ext)).toBe(mime);
|
||||
}
|
||||
|
||||
for (const [type, exts] of Object.entries(tiny.Q)) {
|
||||
for (const ext of exts) {
|
||||
const ex = `${type}/${ext}`;
|
||||
try {
|
||||
expect(large.guessMimeType("." + ext)).toBe(ex);
|
||||
} catch (e) {
|
||||
console.log(`Failed for ${ext}`, {
|
||||
type,
|
||||
exts,
|
||||
ext,
|
||||
expected: ex,
|
||||
actual: large.guessMimeType("." + ext)
|
||||
});
|
||||
throw new Error(`Failed for ${ext}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user