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();
|
2026-04-03 13:53:22 +00:00
|
|
|
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 });
|
2026-04-03 13:53:22 +00:00
|
|
|
const content = createProcessedContent({ frontmatter: { title: "Draft post", draft: true } });
|
2026-02-06 16:23:54 +00:00
|
|
|
|
|
|
|
|
expect(filter.shouldPublish(ctx, content)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|