38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { publicationIssues } from "@/lib/guides/publication";
|
|
|
|
const complete = {
|
|
exists: true,
|
|
overview: "Build overview",
|
|
coverReady: true,
|
|
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,
|
|
renderableSectionCount: 0,
|
|
expectedVersion: 3,
|
|
})).toEqual([
|
|
"กรุณากรอก Overview",
|
|
"รูปปกยังไม่พร้อมใช้งาน",
|
|
"กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section",
|
|
"Guide ถูกแก้ไขแล้ว กรุณาลองใหม่",
|
|
]);
|
|
});
|
|
|
|
it("stops at not found", () => {
|
|
expect(publicationIssues({ ...complete, exists: false })).toEqual(["ไม่พบ Guide"]);
|
|
});
|
|
});
|