feat: Admin Area General Settings and Categories 1.01
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { deriveEventState, endAfterStartValidator, toDatetimeLocal, toIsoUtc } from '../../frontend/src/app/features/admin/general.pure';
|
||||
import {
|
||||
deriveEventState,
|
||||
endAfterStartValidator,
|
||||
normalizePageTitle,
|
||||
pageTitleError,
|
||||
toDatetimeLocal,
|
||||
toIsoUtc,
|
||||
} from '../../frontend/src/app/features/admin/general.pure';
|
||||
|
||||
describe('deriveEventState', () => {
|
||||
const start = '2026-01-01T00:00:00Z';
|
||||
@@ -80,3 +87,42 @@ describe('datetime helpers', () => {
|
||||
expect(toIsoUtc('')).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('pageTitleError', () => {
|
||||
it('returns "required" for empty input', () => {
|
||||
expect(pageTitleError('')).toBe('required');
|
||||
expect(pageTitleError(null)).toBe('required');
|
||||
expect(pageTitleError(undefined)).toBe('required');
|
||||
});
|
||||
|
||||
it('returns "required" for whitespace-only input', () => {
|
||||
expect(pageTitleError(' ')).toBe('required');
|
||||
expect(pageTitleError('\t\n ')).toBe('required');
|
||||
});
|
||||
|
||||
it('returns null for a valid title', () => {
|
||||
expect(pageTitleError('OpenVelo')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns "maxlength" when the raw string exceeds 120 characters', () => {
|
||||
expect(pageTitleError('a'.repeat(121))).toBe('maxlength');
|
||||
});
|
||||
|
||||
it('returns null when surrounding whitespace keeps the trimmed length within bounds', () => {
|
||||
expect(pageTitleError(' OpenVelo ')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizePageTitle', () => {
|
||||
it('returns an empty string for empty input', () => {
|
||||
expect(normalizePageTitle('')).toBe('');
|
||||
});
|
||||
|
||||
it('returns an empty string for whitespace-only input', () => {
|
||||
expect(normalizePageTitle(' ')).toBe('');
|
||||
});
|
||||
|
||||
it('trims surrounding whitespace from a valid title', () => {
|
||||
expect(normalizePageTitle(' OpenVelo ')).toBe('OpenVelo');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user