refactor: move person domain components and utils to lib/person/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
40
frontend/src/lib/person/person-validation.test.ts
Normal file
40
frontend/src/lib/person/person-validation.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { validatePersonFields } from './person-validation';
|
||||
|
||||
describe('validatePersonFields', () => {
|
||||
it('returns null when all required fields are present for PERSON', () => {
|
||||
expect(validatePersonFields('PERSON', 'Hans', 'Müller')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns lastName error key when lastName is missing', () => {
|
||||
expect(validatePersonFields('PERSON', 'Hans', '')).toBe('validation_last_name_required');
|
||||
});
|
||||
|
||||
it('returns lastName error key when lastName is undefined', () => {
|
||||
expect(validatePersonFields('INSTITUTION', undefined, undefined)).toBe(
|
||||
'validation_last_name_required'
|
||||
);
|
||||
});
|
||||
|
||||
it('returns firstName error key when type is PERSON and firstName is missing', () => {
|
||||
expect(validatePersonFields('PERSON', '', 'Müller')).toBe('validation_first_name_required');
|
||||
});
|
||||
|
||||
it('returns firstName error key when type is PERSON and firstName is undefined', () => {
|
||||
expect(validatePersonFields('PERSON', undefined, 'Müller')).toBe(
|
||||
'validation_first_name_required'
|
||||
);
|
||||
});
|
||||
|
||||
it('returns null for INSTITUTION without firstName', () => {
|
||||
expect(validatePersonFields('INSTITUTION', undefined, 'Verlag GmbH')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for GROUP without firstName', () => {
|
||||
expect(validatePersonFields('GROUP', undefined, 'Familie Raddatz')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for UNKNOWN without firstName', () => {
|
||||
expect(validatePersonFields('UNKNOWN', undefined, 'Unbekannt')).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user