Files
community-rule/tests/unit/legalSyntheticPost.test.ts
T

33 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
buildLegalSyntheticPost,
legalPathForSlug,
} from "../../lib/legalSyntheticPost";
describe("legalSyntheticPost", () => {
it("maps slugs to public paths", () => {
expect(legalPathForSlug("privacy")).toBe("/privacy");
expect(legalPathForSlug("terms")).toBe("/terms");
expect(legalPathForSlug("cookies")).toBe("/cookies");
expect(legalPathForSlug("kit")).toBe("/kit");
});
it("builds a guide-shaped post from page messages", () => {
const post = buildLegalSyntheticPost("privacy", {
banner: {
title: "Privacy Policy",
description: "How we handle information.",
author: "Media Economies Design Lab",
date: "2026-08-15",
},
updated: "Last updated August 15, 2026.",
intro: ["Hello."],
sections: [{ heading: "What we collect", paragraphs: ["Email."] }],
});
expect(post.slug).toBe("__legal__:privacy");
expect(post.frontmatter.title).toBe("Privacy Policy");
expect(post.filePath).toBe("messages/en/pages/privacy.json");
});
});