ff21ec921a
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.
23 lines
748 B
TypeScript
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"));
|
|
});
|