Add graph export and chain traversal commands; enhance linting options
- Introduced commands for exporting graph data and displaying chains from the current note. - Enhanced linting functionality with options for showing canonical hints and specifying chain traversal direction. - Added new utility functions for graph traversal and index building. - Updated settings interface to include new options for user configuration.
This commit is contained in:
1 parent
9b8550c387
commit
d577283af6
20 files changed
+2008
-208
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { extractFrontmatterId } from "../../parser/parseFrontmatter";
|
||||
|
||||
describe("extractFrontmatterId", () => {
|
||||
it("extracts id from frontmatter", () => {
|
||||
const md = `---
|
||||
id: test-id
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("test-id");
|
||||
});
|
||||
|
||||
it("returns null when no frontmatter", () => {
|
||||
const md = `Content without frontmatter.`;
|
||||
expect(extractFrontmatterId(md)).toBe(null);
|
||||
});
|
||||
|
||||
it("returns null when no id field", () => {
|
||||
const md = `---
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe(null);
|
||||
});
|
||||
|
||||
it("converts numeric id to string", () => {
|
||||
const md = `---
|
||||
id: 123
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("123");
|
||||
});
|
||||
|
||||
it("handles quoted id", () => {
|
||||
const md = `---
|
||||
id: "quoted-id"
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("quoted-id");
|
||||
});
|
||||
|
||||
it("handles single-quoted id", () => {
|
||||
const md = `---
|
||||
id: 'single-quoted'
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("single-quoted");
|
||||
});
|
||||
|
||||
it("handles id with colon in value", () => {
|
||||
const md = `---
|
||||
id: "id:with:colons"
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("id:with:colons");
|
||||
});
|
||||
|
||||
it("returns null when frontmatter not closed", () => {
|
||||
const md = `---
|
||||
id: test-id
|
||||
title: Test
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe(null);
|
||||
});
|
||||
|
||||
it("handles id without space after colon", () => {
|
||||
const md = `---
|
||||
id:test-id
|
||||
title: Test
|
||||
---
|
||||
|
||||
Content here.
|
||||
`;
|
||||
expect(extractFrontmatterId(md)).toBe("test-id");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user