import { InitialsPipe } from './initials.pipe';

describe('InitialsPipe', () => {
  let pipe: InitialsPipe;

  beforeEach(() => {
    pipe = new InitialsPipe();
  });

  it('should create an instance', () => {
    expect(pipe).toBeTruthy();
  });

  it('should return initials for two words', () => {
    expect(pipe.transform('Juan Pérez')).toBe('JP');
  });

  it('should return initials for three words', () => {
    expect(pipe.transform('María García López')).toBe('ML');
  });

  it('should return single initial for single word', () => {
    expect(pipe.transform('Carlos')).toBe('C');
  });

  it('should handle empty string', () => {
    expect(pipe.transform('')).toBe('');
  });

  it('should handle null-like values', () => {
    expect(pipe.transform(null as any)).toBe('');
    expect(pipe.transform(undefined as any)).toBe('');
  });

  it('should uppercase initials', () => {
    expect(pipe.transform('ana maría')).toBe('AM');
  });

  it('should handle extra whitespace', () => {
    expect(pipe.transform('  Juan   Pérez  ')).toBe('JP');
  });
});
