31 lines
705 B
TypeScript
31 lines
705 B
TypeScript
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)
|
|
})
|
|
})
|