Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
33 lines
1.9 KiB
TypeScript
33 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { BLOCK_TYPES, ICONS, LOOKS, emptyBlock, emptyPage, pageBody } from "./cmsPages";
|
|
|
|
// add-page-sections: the new block types in the editor model and the save body.
|
|
describe("cmsPages: sections", () => {
|
|
it("offers the four new types, the server's icon list and looks", () => {
|
|
expect(BLOCK_TYPES).toEqual(expect.arrayContaining(["FEATURES", "STEPS", "TRUST", "CTA"]));
|
|
expect(Object.keys(ICONS).sort()).toEqual(["calendar", "cloud", "headset", "lock", "monitor", "phone", "shield-check", "star", "tv", "users", "wifi", "wrench"]);
|
|
expect(LOOKS).toEqual(["DEFAULT", "MUTED", "DARK", "ACCENT"]);
|
|
});
|
|
|
|
it("starts each card section with the minimum cards and only the fields its type uses", () => {
|
|
expect(emptyBlock("FEATURES")).toEqual({ type: "FEATURES", heading: "", text: "", cards: [{ icon: "star", title: "", text: "" }, { icon: "star", title: "", text: "" }] });
|
|
expect(emptyBlock("STEPS")).toEqual({ type: "STEPS", heading: "", cards: [{ title: "", text: "" }, { title: "", text: "" }] });
|
|
expect(emptyBlock("TRUST")).toEqual({ type: "TRUST", cards: [{ title: "" }, { title: "" }] });
|
|
expect(emptyBlock("CTA")).toEqual({ type: "CTA", heading: "", text: "", buttonLabel: "", buttonUrl: "" });
|
|
});
|
|
|
|
it("trims card fields and drops a default look on save", () => {
|
|
const body = pageBody({
|
|
...emptyPage(), title: "T", slug: "t",
|
|
blocks: [
|
|
{ type: "STEPS", heading: " How ", look: "DEFAULT", cards: [{ title: " Survey ", text: " We visit. " }, { title: "Fit", text: "" }] },
|
|
{ type: "CTA", heading: "Go", look: "DARK", buttonLabel: "Join", buttonUrl: "#signup" },
|
|
],
|
|
});
|
|
expect(body.blocks).toEqual([
|
|
{ type: "STEPS", heading: "How", cards: [{ title: "Survey", text: "We visit." }, { title: "Fit", text: "" }] },
|
|
{ type: "CTA", heading: "Go", look: "DARK", buttonLabel: "Join", buttonUrl: "#signup" },
|
|
]);
|
|
});
|
|
});
|