Files
RuneStone/tests/unit/links/workspaceFileLink.spec.ts
T
Knotty Wyvern e433bed28e Move the tests from scripts/ to tests/ by feature
Unit tests go to tests/unit/<area>/, browser smoke tests to
tests/smoke/<area>/, and tests against a running desktop app to
tests/native/. Files named after dates, work passes, or Kanban cards get
feature names, for example editorOctober12 -> editor/footnotes.

scripts/ keeps the build, release, and package tools. Plugin repositories
import scripts/packagePlugin.mjs, and the Terminal smoke test imports
scripts/pluginMocks.mjs, which now re-exports the harness copy.

The unit tests get their own type check (tests/tsconfig.json) with Node
types. pnpm check runs it after the app check. Add @types/node and fix
the three test mocks that it reported.
2026-10-27 19:47:39 -07:00

17 lines
943 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { workspaceFileLink } from "../../../src/lib/editor/workspaceFileLink.ts";
import { wordAt } from "../../../src/lib/editor/spellingWord.ts";
test("file links resolve across nested folders and escape Markdown punctuation", () => {
assert.equal(workspaceFileLink("notes/deep/source.md", "docs/a [draft](1).pdf"), "[a \\[draft\\](1).pdf](../../docs/a%20%5Bdraft%5D%281%29.pdf)");
assert.equal(workspaceFileLink("notes/source.md", "notes/target.md"), "[target.md](target.md)");
assert.equal(workspaceFileLink("notes/source.md", "assets/pic.png"), "![](../assets/pic.png)");
});
test("spelling finds Unicode words and apostrophes without including punctuation", () => {
assert.deepEqual(wordAt("A naïve word.", 5), { word: "naïve", from: 2, to: 7 });
assert.equal(wordAt("Don't stop", 3)?.word, "Don't");
assert.equal(wordAt("word next", 5), null);
});