Files
fegger ff21ec921a Add test script and initial test suite
The test runner bundles TypeScript tests with esbuild and executes them using Node's built-in test runner. Tests cover
document downloader behavior, path utilities, rmapi bridge configuration, style refinement, and ZIP file handling. Mock
implementations for Obsidian plugin interfaces enable isolated unit testing.
2026-05-31 16:33:30 +02:00

35 lines
1.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { StyleRefiner } from "../src/ocr/style-refiner";
function createRefiner(response: string): any {
const refiner: any = new StyleRefiner({
settings: {
ollamaHost: "http://localhost:11435",
styleModel: "qwen3:32b",
},
} as any);
refiner.queryOllama = async () => response;
return refiner;
}
test("refineMarkdown rejects empty Ollama output", async () => {
const refiner = createRefiner("");
await assert.rejects(() => refiner.refineMarkdown("Some source Markdown"), /empty Markdown/);
});
test("mergeAndRefine rejects unexpectedly short output for large inputs", async () => {
const refiner = createRefiner("too short");
const largeInput = "handwritten note ".repeat(80);
await assert.rejects(() => refiner.mergeAndRefine(largeInput, ""), /unexpectedly short/);
});
test("mergeAndRefine returns acceptable Ollama output", async () => {
const output = "# Heading\n\n" + "content ".repeat(120);
const refiner = createRefiner(output);
assert.equal(await refiner.mergeAndRefine("content ".repeat(80), ""), output.trim());
});