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

23 lines
748 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { join } from "path";
import { vaultPathToAbsolute, vaultRelativePath } from "../src/utils/paths";
test("vaultRelativePath normalizes vault paths and drops traversal segments", () => {
assert.equal(vaultRelativePath("remarkable/", "/Folder", ".", "..", "Note.rm"), "remarkable/Folder/Note.rm");
});
test("vaultPathToAbsolute resolves vault-relative paths under the vault root", () => {
const plugin = {
app: {
vault: {
adapter: {
getBasePath: () => "/tmp/vault",
},
},
},
};
assert.equal(vaultPathToAbsolute(plugin as any, "remarkable/Folder/Note.rm"), join("/tmp/vault", "remarkable", "Folder", "Note.rm"));
});