Files
buzz-sheet/lib/guides/publication.test.ts
T
gunshiz 9896e8a4ad
CI / Verify (push) Successful in 1m35s
CI / Build immutable images and deploy (push) Successful in 5m27s
feat(guides) : add safer publishing and discovery
2026-09-19 13:32:57 +07:00

41 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { publicationIssues } from "@/lib/guides/publication";
const complete = {
exists: true,
overview: "Build overview",
coverReady: true,
catalogVersion: "6.0",
renderableSectionCount: 1,
version: 4,
expectedVersion: 4,
};
describe("publicationIssues", () => {
it("accepts a complete persisted guide", () => {
expect(publicationIssues(complete)).toEqual([]);
});
it("reports every incomplete core requirement", () => {
expect(publicationIssues({
...complete,
overview: " ",
coverReady: false,
catalogVersion: null,
renderableSectionCount: 0,
expectedVersion: 3,
})).toEqual([
"กรุณากรอก Overview",
"รูปปกยังไม่พร้อมใช้งาน",
"กรุณา Sync Catalog ก่อนเผยแพร่",
"กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section",
"Guide ถูกแก้ไขแล้ว กรุณาลองใหม่",
]);
});
it("stops at not found", () => {
expect(publicationIssues({ ...complete, exists: false })).toEqual(["ไม่พบ Guide"]);
});
});