From f0fe3d6ca24624d955a4f4e62e5aafabe053f29e Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Mon, 9 Mar 2026 03:21:37 +0100 Subject: [PATCH] fix: remove template boilerplate test files and add passWithNoTests --- test/emitter.test.ts | 45 ---------------------------------------- test/filter.test.ts | 21 ------------------- test/helpers.ts | 41 ------------------------------------ test/transformer.test.ts | 22 -------------------- vitest.config.ts | 1 + 5 files changed, 1 insertion(+), 129 deletions(-) delete mode 100644 test/emitter.test.ts delete mode 100644 test/filter.test.ts delete mode 100644 test/helpers.ts delete mode 100644 test/transformer.test.ts diff --git a/test/emitter.test.ts b/test/emitter.test.ts deleted file mode 100644 index 67b31e1..0000000 --- a/test/emitter.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { describe, expect, it } from "vitest"; -import path from "node:path"; -import fs from "node:fs/promises"; -import { tmpdir } from "node:os"; -import { ExampleEmitter } from "../src/emitter"; -import { createCtx, createProcessedContent } from "./helpers"; - -describe("ExampleEmitter", () => { - it("writes a manifest to the output directory", async () => { - const outputDir = await fs.mkdtemp(path.join(tmpdir(), "quartz-plugin-")); - const ctx = createCtx({ argv: { output: outputDir } }); - const emitter = ExampleEmitter({ manifestSlug: "manifest" }); - - const content = [ - createProcessedContent({ - slug: "hello-world", - filePath: "notes/hello-world.md", - frontmatter: { title: "Hello", tags: ["docs"] }, - }), - ]; - - const result = await emitter.emit(ctx, content, { - css: [], - js: [], - additionalHead: [], - }); - const outputPaths = Array.isArray(result) ? result : await collectAsync(result); - const outputPath = outputPaths[0]; - if (!outputPath) { - throw new Error("Expected emitter to return an output path"); - } - const manifest = JSON.parse(await fs.readFile(outputPath, "utf8")); - - expect(outputPath).toContain("manifest.json"); - expect(manifest.pages[0].slug).toBe("hello-world"); - }); -}); - -const collectAsync = async (iterable: AsyncIterable): Promise => { - const results: T[] = []; - for await (const item of iterable) { - results.push(item); - } - return results; -}; diff --git a/test/filter.test.ts b/test/filter.test.ts deleted file mode 100644 index 514069a..0000000 --- a/test/filter.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { ExampleFilter } from "../src/filter"; -import { createCtx, createProcessedContent } from "./helpers"; - -describe("ExampleFilter", () => { - it("filters drafts by default", () => { - const ctx = createCtx(); - const filter = ExampleFilter(); - const content = createProcessedContent({ frontmatter: { draft: true } }); - - expect(filter.shouldPublish(ctx, content)).toBe(false); - }); - - it("allows drafts when configured", () => { - const ctx = createCtx(); - const filter = ExampleFilter({ allowDrafts: true }); - const content = createProcessedContent({ frontmatter: { draft: true } }); - - expect(filter.shouldPublish(ctx, content)).toBe(true); - }); -}); diff --git a/test/helpers.ts b/test/helpers.ts deleted file mode 100644 index 4974b70..0000000 --- a/test/helpers.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { - BuildCtx, - QuartzConfig, - ProcessedContent, - QuartzPluginData, -} from "@quartz-community/types"; -import { VFile } from "vfile"; - -type BuildCtxOverrides = Omit, "argv"> & { - argv?: Partial; -}; - -export const createCtx = (overrides: BuildCtxOverrides = {}): BuildCtx => { - const { argv: argvOverrides, ...rest } = overrides; - const argv: BuildCtx["argv"] = { - directory: "content", - verbose: false, - output: "dist", - serve: false, - watch: false, - port: 0, - wsPort: 0, - ...argvOverrides, - }; - - return { - buildId: "test-build", - argv, - cfg: {} as QuartzConfig, - allSlugs: [], - allFiles: [], - incremental: false, - ...rest, - }; -}; - -export const createProcessedContent = (data: Partial = {}): ProcessedContent => { - const vfile = new VFile(""); - vfile.data = data; - return [{ type: "root", children: [] }, vfile]; -}; diff --git a/test/transformer.test.ts b/test/transformer.test.ts deleted file mode 100644 index e5db05d..0000000 --- a/test/transformer.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { unified } from "unified"; -import remarkParse from "remark-parse"; -import remarkStringify from "remark-stringify"; -import { ExampleTransformer } from "../src/transformer"; -import { createCtx } from "./helpers"; - -describe("ExampleTransformer", () => { - it("highlights text wrapped in the token", async () => { - const ctx = createCtx(); - const transformer = ExampleTransformer({ highlightToken: "==" }); - const plugins = transformer.markdownPlugins?.(ctx) ?? []; - - const file = await unified() - .use(remarkParse) - .use(plugins) - .use(remarkStringify) - .process("Hello ==Quartz=="); - - expect(String(file)).toContain("**Quartz**"); - }); -}); diff --git a/vitest.config.ts b/vitest.config.ts index d7d0fa2..91100b5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,6 +4,7 @@ export default defineConfig({ test: { environment: "node", include: ["test/**/*.test.ts"], + passWithNoTests: true, reporters: ["default"], }, });