aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/assistant/test_files.js
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/assistant/test_files.js')
-rw-r--r--desktop/assistant/test_files.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/desktop/assistant/test_files.js b/desktop/assistant/test_files.js
index 80a855d..f2a65ca 100644
--- a/desktop/assistant/test_files.js
+++ b/desktop/assistant/test_files.js
@@ -18,7 +18,7 @@ const assert = require("assert");
const src = fs.readFileSync(__dirname + "/Files.js", "utf8")
.replace(/^\.pragma library$/m, "");
-const F = new Function(src + "\nreturn { kind, chats, fromUrl, file, name };")();
+const F = new Function(src + "\nreturn { kind, chats, fromUrl, file, name, fromMime };")();
const cases = {
"/a/report.pdf": "pdf", "/a/Report.PDF": "pdf", "/a/x.png": "image", "/a/x.JPEG": "image",
@@ -40,4 +40,14 @@ assert.strictEqual(F.fromUrl("file://otherhost/tmp/a.pdf"), "");
assert.strictEqual(F.fromUrl("file:///bad%E0%A4%A"), ""); // malformed escape
assert.deepStrictEqual(F.file("/x/y/a b.pdf"), { path: "/x/y/a b.pdf", name: "a b.pdf", kind: "pdf" });
+// A file the name says nothing about is told by its mime type (file -b).
+const mimes = {
+ "text/x-shellscript": "code", "text/x-script.python": "code", "text/x-c": "code",
+ "text/x-makefile": "code", "application/json": "code", "text/plain": "text",
+ "text/csv": "text", "text/markdown": "text", "image/png": "image", "application/pdf": "pdf",
+ "video/mp4": "video", "application/zip": "archive", "application/x-xz": "archive",
+ "application/octet-stream": "other", "application/x-executable": "other", "": "other",
+};
+for (const [m, k] of Object.entries(mimes)) assert.strictEqual(F.fromMime(m), k, m);
+
console.log("ok");