create-theokit 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-theokit",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "description": "Scaffold a new TheoKit project",
6
6
  "license": "Apache-2.0",
@@ -1,10 +1,38 @@
1
1
  import { describe, it, expect } from 'vitest'
2
+ import { z } from 'zod'
2
3
 
3
- describe('Tasks API', () => {
4
- it('GET /api/tasks returns array', async () => {
5
- const res = await fetch('http://localhost:3000/api/tasks')
6
- expect(res.status).toBe(200)
7
- const tasks = await res.json()
8
- expect(Array.isArray(tasks)).toBe(true)
4
+ // Schema mirrors server/routes/tasks/index.ts POST body validation.
5
+ // Unit test — no server dependency.
6
+ const taskBodySchema = z.object({
7
+ title: z.string().min(3),
8
+ done: z.boolean().default(false),
9
+ })
10
+
11
+ describe('Task body validation', () => {
12
+ it('accepts valid task', () => {
13
+ const result = taskBodySchema.safeParse({ title: 'Buy groceries' })
14
+ expect(result.success).toBe(true)
15
+ if (result.success) {
16
+ expect(result.data.title).toBe('Buy groceries')
17
+ expect(result.data.done).toBe(false)
18
+ }
19
+ })
20
+
21
+ it('defaults done to false', () => {
22
+ const result = taskBodySchema.safeParse({ title: 'New task' })
23
+ expect(result.success).toBe(true)
24
+ if (result.success) expect(result.data.done).toBe(false)
25
+ })
26
+
27
+ it('rejects title shorter than 3 characters', () => {
28
+ expect(taskBodySchema.safeParse({ title: 'ab' }).success).toBe(false)
29
+ })
30
+
31
+ it('rejects empty title', () => {
32
+ expect(taskBodySchema.safeParse({ title: '' }).success).toBe(false)
33
+ })
34
+
35
+ it('rejects missing title', () => {
36
+ expect(taskBodySchema.safeParse({ done: true }).success).toBe(false)
9
37
  })
10
38
  })