plugin-template/test/filter.test.ts

22 lines
767 B
TypeScript
Raw Permalink Normal View History

2026-02-06 16:23:54 +00:00
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: { title: "Draft post", draft: true } });
2026-02-06 16:23:54 +00:00
expect(filter.shouldPublish(ctx, content)).toBe(false);
});
it("allows drafts when configured", () => {
const ctx = createCtx();
const filter = ExampleFilter({ allowDrafts: true });
const content = createProcessedContent({ frontmatter: { title: "Draft post", draft: true } });
2026-02-06 16:23:54 +00:00
expect(filter.shouldPublish(ctx, content)).toBe(true);
});
});