reformat + add testing utils, test dev plugin fully
Some checks failed
/ build (node-16) (push) Successful in 12s
/ build (windows-node-iron) (push) Failing after 1m48s

This commit is contained in:
Soph :3 2025-10-20 11:28:18 +03:00
parent 0259a96937
commit 4d8a9dff8e
15 changed files with 242 additions and 158 deletions

View file

@ -1,7 +1,6 @@
import { expect, test } from "bun:test";
import MarkdownCompiler from "../markdown-compiler";
// Mock marked and parseMetadata for isolated testing
const mockMarked = {
parse: (text: string) => `<p>${text}</p>`,
};
@ -12,7 +11,6 @@ const mockParseMetadata = (file: string) => {
return undefined;
};
// Patch dependencies
// @ts-expect-error
MarkdownCompiler.prototype["marked"] = mockMarked;
// @ts-expect-error
@ -21,7 +19,7 @@ MarkdownCompiler.prototype["parseMetadata"] = mockParseMetadata;
test("MarkdownCompiler compiles markdown to HTML", async () => {
const plugin = new MarkdownCompiler();
const input = "# Hello World";
// Simulate marked.parse
const output = await plugin.rewriteFile(input, "test.md");
expect(typeof output).toBe("string");
expect(output).toContain("Hello World");