feat: Admin Area General Settings and Categories 1.02
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
endAfterStartValidator,
|
||||
normalizePageTitle,
|
||||
pageTitleError,
|
||||
pageTitleMessage,
|
||||
toDatetimeLocal,
|
||||
toIsoUtc,
|
||||
} from '../../frontend/src/app/features/admin/general.pure';
|
||||
@@ -126,3 +127,37 @@ describe('normalizePageTitle', () => {
|
||||
expect(normalizePageTitle(' OpenVelo ')).toBe('OpenVelo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('pageTitleMessage', () => {
|
||||
const requiredMsg = 'Page title is required and cannot contain only whitespace.';
|
||||
const maxLengthMsg = 'Page title must be 120 characters or fewer.';
|
||||
|
||||
it('returns the required message for empty input', () => {
|
||||
expect(pageTitleMessage('', null)).toBe(requiredMsg);
|
||||
});
|
||||
|
||||
it('returns the required message for whitespace-only input', () => {
|
||||
expect(pageTitleMessage(' ', null)).toBe(requiredMsg);
|
||||
expect(pageTitleMessage('\t\n ', null)).toBe(requiredMsg);
|
||||
});
|
||||
|
||||
it('returns null for a valid title', () => {
|
||||
expect(pageTitleMessage('OpenVelo', null)).toBeNull();
|
||||
});
|
||||
|
||||
it('returns the maxlength message when the raw string exceeds 120 characters', () => {
|
||||
expect(pageTitleMessage('a'.repeat(121), null)).toBe(maxLengthMsg);
|
||||
});
|
||||
|
||||
it('surfaces the whitespace validator error when control errors are provided', () => {
|
||||
expect(pageTitleMessage(' ', { whitespace: true })).toBe(requiredMsg);
|
||||
});
|
||||
|
||||
it('surfaces the required control error', () => {
|
||||
expect(pageTitleMessage('', { required: true })).toBe(requiredMsg);
|
||||
});
|
||||
|
||||
it('surfaces the maxlength control error', () => {
|
||||
expect(pageTitleMessage('a'.repeat(121), { maxlength: { requiredLength: 120 } })).toBe(maxLengthMsg);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user