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

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

    const profilePresenter = new ProfilePresenter();
    const viewModel = profilePresenter.toViewModel(profile);

    expect(viewModel).toEqual({
      id: profile.id,
      fullName: '', // transformation OK
      isVerifiedLabel: '✅ Vérifié',
      estVerifier: true,
      coordonnees: { latitude: 0, longitude: 0 } as Coordinates,
      profession: 'Développeur Web'.toUpperCase(),
      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: 'http://localhost:8090/api/files/profiles/1/cv.pdf',
      isProfileVisible: true,
      missingFields: [],
      projets: ['p1', 'p2'],
      settings: {
        showEmail: false,
        showPhone: false,
        allowGeolocation: false,
        isProfilePublic: false,
      },
    });
  });

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

    const profilePresenter = new ProfilePresenter();
    const viewModel = profilePresenter.toViewModel(profile);

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

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

    expect(result.length).toBe(2);
    expect(result[0].fullName).toBe('');
  });
});
