refactor(notes): extract title validation into domain service

This commit is contained in:
devcodetools committed 2026-09-13 16:58:12 +02:00
1 parent 557e48116a
commit 5aeeb21f7f
3 files changed
+37 -3

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest'
import { isTitleValid, normalizeTitle } from './noteValidation'
describe('isTitleValid', () => {
it('accepts a non-empty title', () => {
expect(isTitleValid('Courses')).toBe(true)
})
it('rejects an empty title', () => {
expect(isTitleValid('')).toBe(false)
})
it('rejects a whitespace-only title', () => {
expect(isTitleValid(' ')).toBe(false)
})
})
describe('normalizeTitle', () => {
it('trims surrounding whitespace', () => {
expect(normalizeTitle(' Courses ')).toBe('Courses')
})
it('keeps an already trimmed title unchanged', () => {
expect(normalizeTitle('Courses')).toBe('Courses')
})
})