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();
	});
});
