import { describe, expect, it } from 'vitest' import { t } from '@/lib/strings' import { noteSchema } from './schema' const err = (title: string, body_md = '') => { const r = noteSchema.safeParse({ title, body_md }) return r.success ? null : r.error.issues[0].message } describe('noteSchema', () => { it('accepts a note with an empty body', () => { expect(err('Hedefler')).toBeNull() }) it('rejects empty and too long titles', () => { expect(err(' ')).toBe(t.notes.titleRequired) expect(err('x'.repeat(121))).toBe(t.notes.titleTooLong) }) it('counts characters like the backend (emoji = 1)', () => { expect(err('🎯'.repeat(120))).toBeNull() // UTF-16'da 240 birim expect(err('Not', '🎯'.repeat(20_000))).toBeNull() expect(err('Not', 'a'.repeat(20_001))).toBe(t.notes.bodyTooLong) }) })