import { test } from 'node:test';
import assert from 'node:assert/strict';
import { USER_NAME_PREFIXES, formatPersonName } from '@/shared/constants/users';

test('formatPersonName prepends the honorific label', () => {
  assert.equal(
    formatPersonName(USER_NAME_PREFIXES.DR, 'Sarah', 'Williams'),
    'Dr. Sarah Williams',
  );
  assert.equal(formatPersonName('mr', 'Alex', 'Morgan'), 'Mr. Alex Morgan');
});

test('formatPersonName omits a missing/unknown prefix', () => {
  assert.equal(formatPersonName(null, 'Emma', 'Clark'), 'Emma Clark');
  assert.equal(formatPersonName('bogus', 'Emma', 'Clark'), 'Emma Clark');
  assert.equal(formatPersonName(undefined, 'Emma', null), 'Emma');
});

test('formatPersonName returns empty string when no name parts exist', () => {
  assert.equal(formatPersonName(null, null, null), '');
});
