Spaces:
Sleeping
Sleeping
File size: 1,514 Bytes
cb43fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import {
todoCreateItemRequestSchema,
todoUpdateItemRequestSchema,
todoReorderRequestSchema,
} from './todo.schema';
import { describe, it, expect } from 'vitest';
describe('todoCreateItemRequestSchema', () => {
it('requires a name; metadata optional with the service shapes', () => {
expect(
todoCreateItemRequestSchema.safeParse({ name: 'Book hotel' }).success,
).toBe(true);
expect(
todoCreateItemRequestSchema.safeParse({
name: 'X',
due_date: '2026-07-01',
priority: 2,
assigned_user_id: 3,
}).success,
).toBe(true);
expect(todoCreateItemRequestSchema.safeParse({ name: '' }).success).toBe(
false,
);
// priority is numeric (matches the service), not a string
expect(
todoCreateItemRequestSchema.safeParse({ name: 'X', priority: 'high' })
.success,
).toBe(false);
});
});
describe('todoUpdateItemRequestSchema', () => {
it('allows every field to be omitted and accepts checked', () => {
expect(todoUpdateItemRequestSchema.safeParse({}).success).toBe(true);
expect(
todoUpdateItemRequestSchema.safeParse({ checked: true }).success,
).toBe(true);
});
});
describe('todoReorderRequestSchema', () => {
it('requires an array of numeric ids', () => {
expect(
todoReorderRequestSchema.safeParse({ orderedIds: [1, 2, 3] }).success,
).toBe(true);
expect(
todoReorderRequestSchema.safeParse({ orderedIds: ['a'] }).success,
).toBe(false);
});
});
|