Todo
This commit is contained in:
30
packages/content/src/index.test.ts
Normal file
30
packages/content/src/index.test.ts
Normal 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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user