Spaces:
Sleeping
Sleeping
File size: 1,448 Bytes
98fbc6d | 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 | import {
dayCreateRequestSchema,
dayNoteCreateRequestSchema,
dayNoteUpdateRequestSchema,
} from './day.schema';
import { describe, it, expect } from 'vitest';
describe('dayCreateRequestSchema', () => {
it('accepts an optional date + notes', () => {
expect(dayCreateRequestSchema.safeParse({}).success).toBe(true);
expect(
dayCreateRequestSchema.safeParse({ date: '2026-07-01', notes: 'n' })
.success,
).toBe(true);
});
});
describe('dayNoteCreateRequestSchema', () => {
it('requires non-empty text capped at 500, time capped at 250', () => {
expect(
dayNoteCreateRequestSchema.safeParse({ text: 'Lunch' }).success,
).toBe(true);
expect(dayNoteCreateRequestSchema.safeParse({ text: '' }).success).toBe(
false,
);
expect(
dayNoteCreateRequestSchema.safeParse({ text: 'x'.repeat(501) }).success,
).toBe(false);
expect(
dayNoteCreateRequestSchema.safeParse({
text: 'ok',
time: 'y'.repeat(251),
}).success,
).toBe(false);
});
});
describe('dayNoteUpdateRequestSchema', () => {
it('allows omitting text and caps the lengths', () => {
expect(dayNoteUpdateRequestSchema.safeParse({}).success).toBe(true);
expect(dayNoteUpdateRequestSchema.safeParse({ icon: '🍽️' }).success).toBe(
true,
);
expect(
dayNoteUpdateRequestSchema.safeParse({ text: 'x'.repeat(501) }).success,
).toBe(false);
});
});
|