-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.test.ts
More file actions
25 lines (22 loc) · 989 Bytes
/
Copy pathparse.test.ts
File metadata and controls
25 lines (22 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { describe, expect, it } from "vitest";
import {
markdownReferencePathCandidatesFromDocument,
normalizeMarkdownReferencePath,
relativeMarkdownReferencePathFromDocument,
resolveMarkdownReferencePathFromDocument,
} from "./parse";
describe("@chaoxu/coflat/parse public path helpers", () => {
it("exposes markdown-authored reference path normalization", () => {
expect(normalizeMarkdownReferencePath("/assets/./figures/../plot.png")).toBe(
"assets/plot.png",
);
});
it("exposes document-relative reference resolution helpers", () => {
expect(resolveMarkdownReferencePathFromDocument("notes/main.md", "assets/plot.png"))
.toBe("notes/assets/plot.png");
expect(markdownReferencePathCandidatesFromDocument("notes/main.md", "refs/library.bib"))
.toEqual(["notes/refs/library.bib", "refs/library.bib"]);
expect(relativeMarkdownReferencePathFromDocument("notes/main.md", "assets/plot.png"))
.toBe("../assets/plot.png");
});
});