Files
kakeibo/frontend/src/features/notes/schema.test.ts
T
suphicakir eca0bb27a0 feat(plan): dönem notları — Markdown, yaz/önizle sekmeleri
- NotesSection: ekle/düzenle/sil (onaylı), yazar ve tarih, kapalı dönemde salt okunur
- Markdown gösterimi (react-markdown + remark-gfm): ham HTML yok, güvenli bağlantılar
- Çakışma (409) mesajı formda; Plan sayfasına bağlandı
- Dağıtım çubuğu boş dönemde "tamamı dağıtıldı" demiyor
- Faz 4 tamamlandı

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 08:55:16 +03:00

26 lines
836 B
TypeScript

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)
})
})