Files
notes/src/lib/noteValidation.test.ts
T

27 lines
689 B
TypeScript

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