Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript
2.4 KB
Raw Blame
import { describe, expect, it } from "vitest"
import {
  getCodeLanguage,
  getFileCategory,
  getFileExtension,
  isExtractedTextPreviewFile,
} from "@/lib/file-types"

describe("file types", () => {
  it("recognizes backend-extracted document previews", () => {
    expect(isExtractedTextPreviewFile("/project/raw/sources/report.doc")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/report.docx")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/report.docm")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/slides.pptx")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/slides.ppsm")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/sheet.xlsx")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/sheet.xlsb")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/notes.rtf")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/book.epub")).toBe(true)
    expect(isExtractedTextPreviewFile("C:\\books\\book.MOBI")).toBe(true)
    expect(isExtractedTextPreviewFile("C:\\notes\\journal.ORG")).toBe(true)
    expect(isExtractedTextPreviewFile("/project/raw/sources/archive.zip")).toBe(false)
  })

  it("classifies EPUB, MOBI, and Org as extracted documents", () => {
    expect(getFileCategory("/project/book.epub")).toBe("document")
    expect(getFileCategory("C:\\books\\book.MOBI")).toBe("document")
    expect(getFileCategory("/project/notes.org")).toBe("document")
  })

  it("extracts extensions from windows and unix paths", () => {
    expect(getFileExtension("C:\\Users\\me\\report.DOC")).toBe("doc")
    expect(getFileExtension("/Users/me/report.docx")).toBe("docx")
    expect(getFileExtension("/Users/me/README")).toBe("")
  })

  it("routes standalone Mermaid sources through the code preview pipeline", () => {
    expect(getFileCategory("/project/diagram.mmd")).toBe("code")
    expect(getFileCategory("C:\\project\\diagram.MERMAID")).toBe("code")
    expect(getCodeLanguage("/project/diagram.mmd")).toBe("mermaid")
  })

  it("classifies extensionless basenames (Dockerfile/Makefile) under a directory as code", () => {
    // Bare names already worked; path-prefixed ones regressed to "unknown" (binary).
    expect(getFileCategory("Dockerfile")).toBe("code")
    expect(getFileCategory("/project/Dockerfile")).toBe("code")
    expect(getFileCategory("C:\\project\\Makefile")).toBe("code")
  })
})