import { ProfilePresenter } from '@app/ui/profiles/profile.presenter';
import { Profile } from '@app/domain/profiles/profile.model';
import { mockProfiles } from '@app/testing/profile.mock';

describe('ProfilePresenter', () => {
  it('devrait transformer un Profile en ProfileViewModel', () => {
    const profile: Profile = mockProfiles[0];

    const viewModel = ProfilePresenter.toViewModel(profile);

    expect(viewModel).toEqual({
      id: profile.id,
      fullName: profile.profession.toUpperCase(), // transformation OK
      isVerifiedLabel: '✅ Vérifié',
      estVerifier: true,
      profession: 'Développeur Web',
      reseaux: { linkedin: 'https://linkedin.com/in/test' },
      secteur: 'Informatique',
      utilisateur: 'user_abc',
      createdAtFormatted: new Date(profile.created).toLocaleDateString(),
      avatarUrl: '',
      apropos: 'Développeur Angular & Node.js',
      bio: 'Passionné de code.',
      cv: 'cv.pdf',
      projets: ['p1', 'p2'],
    });
  });

  it('devrait retourner ❌ Non vérifié si estVerifier = false', () => {
    const profile = { ...mockProfiles[1], estVerifier: false };

    const vm = ProfilePresenter.toViewModel(profile);

    expect(vm.isVerifiedLabel).toBe('❌ Non vérifié');
  });

  it('devrait transformer un tableau complet', () => {
    const result = ProfilePresenter.toViewModels(mockProfiles);

    expect(result.length).toBe(2);
    expect(result[0].fullName).toBe(mockProfiles[0].profession.toUpperCase());
  });
});
