import { describe, it, expect } from 'vitest'
import { shortDisplayName } from '../display-name'

describe('shortDisplayName', () => {
  it('abbreviates the first name to an initial', () => {
    expect(shortDisplayName('Karim Aseckzai')).toBe('K. Aseckzai')
    expect(shortDisplayName('Kais Aseckzai')).toBe('K. Aseckzai')
  })

  it('keeps only first-initial + last token for multi-part names', () => {
    expect(shortDisplayName('Anna Maria Müller')).toBe('A. Müller')
  })

  it('returns a single-word name unchanged', () => {
    expect(shortDisplayName('Max')).toBe('Max')
    expect(shortDisplayName('mustermann')).toBe('mustermann')
  })

  it('trims and collapses whitespace', () => {
    expect(shortDisplayName('  Karim   Mustermann  ')).toBe('K. Mustermann')
  })

  it('handles empty / falsy input', () => {
    expect(shortDisplayName('')).toBe('')
    expect(shortDisplayName('   ')).toBe('')
  })
})
