Files
plainleaf/plugs/index/page.test.ts
T
Zef Hemel 02bd8ed362 Migration Deno -> Node.js
* First pass
* Now using vitest for tests
2026-02-14 22:08:35 +01:00

37 lines
903 B
TypeScript

import { expect, test } from "vitest";
import { parseMarkdown } from "../../client/markdown_parser/parser.ts";
import { createMockSystem } from "../../plug-api/system_mock.ts";
import type { PageMeta } from "@silverbulletmd/silverbullet/type/index";
import { indexPage } from "./page.ts";
import { extractFrontMatter } from "./frontmatter.ts";
const testPage = `
---
hello: attribute
---
[hello2: 12]
# Hello world!
`.trim();
test("Test page indexing", async () => {
createMockSystem();
const tree = parseMarkdown(testPage);
const frontmatter = extractFrontMatter(tree);
const pageMeta: PageMeta = {
ref: "test",
name: "test",
tag: "page",
created: "",
lastModified: "",
perm: "rw",
};
const [pm] = await indexPage(pageMeta, frontmatter, tree);
expect(pm.hello).toEqual("attribute");
expect(pm.hello2).toEqual(12);
expect(pm.itags).toEqual(["page"]);
});