nandi/oripublic Fork 0
f5c963af3c1597c0274ce4a99705dbd92a7d1cba
Commits
Clone
git clone https://git.rickub.com/nandi/ori.git
git clone ssh://git@rickub.com/nandi/ori.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

forked from bots-garden/ori

lang.test.ts · 61 lines · 1.8 KBTypeScript Blame HistoryRaw
✨ Workspace panel, selectors, previews, desktop app, sandbox template, resizable file tree, light/dark theme 76d62ac k33g yesterday1import { describe, expect, it } from "vitest";
2import { kindForPath, languageForPath } from "./lang";
3
4describe("languageForPath", () => {
5 it("maps common extensions to Monaco language ids", () => {
6 expect(languageForPath("/w/main.go")).toBe("go");
7 expect(languageForPath("src/App.tsx")).toBe("typescript");
8 expect(languageForPath("script.py")).toBe("python");
9 expect(languageForPath("style.css")).toBe("css");
10 expect(languageForPath("run.sh")).toBe("shell");
11 expect(languageForPath("doc.md")).toBe("markdown");
12 });
13
14 it("recognises well-known extensionless files", () => {
15 expect(languageForPath("/w/Makefile")).toBe("makefile");
16 expect(languageForPath("/w/Dockerfile")).toBe("dockerfile");
17 });
18
19 it("falls back to plaintext", () => {
20 expect(languageForPath("notes.xyz")).toBe("plaintext");
21 expect(languageForPath("LICENSE")).toBe("plaintext");
22 expect(languageForPath(".gitignore")).toBe("plaintext");
23 });
24});
25
26describe("kindForPath", () => {
27 it("detects markdown and asciidoc", () => {
28 expect(kindForPath("README.md")).toBe("markdown");
29 expect(kindForPath("book.adoc")).toBe("asciidoc");
30 expect(kindForPath("book.asciidoc")).toBe("asciidoc");
31 });
32
33 it("detects images, including draw.io exports", () => {
34 for (const name of [
35 "a.png",
36 "b.JPG",
37 "c.jpeg",
38 "d.gif",
39 "e.webp",
40 "f.svg",
41 "g.bmp",
42 "h.ico",
43 "i.avif",
44 "diagram.drawio.svg",
45 "diagram.drawio.png",
46 ]) {
47 expect(kindForPath(name), name).toBe("image");
48 }
49 });
50
51 it("detects draw.io XML diagrams", () => {
52 expect(kindForPath("docs/diagrams/packages.drawio")).toBe("drawio");
53 expect(kindForPath("flow.dio")).toBe("drawio");
54 expect(languageForPath("flow.drawio")).toBe("xml");
55 });
56
57 it("treats everything else as code", () => {
58 expect(kindForPath("main.go")).toBe("code");
59 expect(kindForPath("LICENSE")).toBe("code");
60 });
61});