This commit is contained in:
2026-02-10 02:06:54 +01:00
parent 5290560d68
commit ef5e98ad5d
29 changed files with 1529 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest"
import { postSchema, upsertPostSchema } from "./index"
describe("content schemas", () => {
it("accepts a valid post", () => {
const post = postSchema.parse({
id: "8f0cb474-4f84-4f3c-aeb5-a9f193f5f701",
title: "Hello world",
slug: "hello-world",
body: "Body",
status: "published",
createdAt: new Date(),
updatedAt: new Date(),
})
expect(post.slug).toBe("hello-world")
})
it("rejects invalid upsert payload", () => {
const result = upsertPostSchema.safeParse({
title: "Hi",
slug: "x",
body: "",
status: "unknown",
})
expect(result.success).toBe(false)
})
})