17 lines
943 B
TypeScript
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"), "");
|
|
});
|
|
|
|
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);
|
|
});
|