MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / createPlugin

Function createPlugin

tests/unit/utils/sortOrderUtils.test.ts:38–70  ·  view source on GitHub ↗
(frontmatterByPath: FrontmatterMap, sortOrderField = "tasknotes_manual_order")

Source from the content-addressed store, hash-verified

36}
37
38function createPlugin(frontmatterByPath: FrontmatterMap, sortOrderField = "tasknotes_manual_order") {
39 const processFrontMatter = jest.fn(async (file: TFile, updater: (frontmatter: any) => void) => {
40 const frontmatter = frontmatterByPath[file.path];
41 if (!frontmatter) {
42 throw new Error(`Missing frontmatter for ${file.path}`);
43 }
44 updater(frontmatter);
45 });
46
47 return {
48 settings: {
49 fieldMapping: {
50 sortOrder: sortOrderField,
51 },
52 },
53 app: {
54 vault: {
55 getMarkdownFiles: jest.fn(() => Object.keys(frontmatterByPath).map((path) => new TFile(path))),
56 getAbstractFileByPath: jest.fn((path: string) => (
57 Object.prototype.hasOwnProperty.call(frontmatterByPath, path) ? new TFile(path) : null
58 )),
59 },
60 metadataCache: {
61 getFileCache: jest.fn((file: TFile) => ({
62 frontmatter: frontmatterByPath[file.path],
63 })),
64 },
65 fileManager: {
66 processFrontMatter,
67 },
68 },
69 } as any;
70}
71
72describe("sortOrderUtils", () => {
73 it("writes the configured sort-order field when applying a plan", async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected