import { mapParentForApi } from './parents.mapper';
import { Parents } from '../../entities/parents.entity';
import { RoleType, StatutUtilisateurType, Users } from '../../entities/users.entity';

describe('mapParentForApi', () => {
  it('expose co_parent avec prenom/nom sans secrets', () => {
    const coParent = {
      id: 'cp1',
      email: 'co@b.fr',
      prenom: 'Clara',
      nom: 'Co',
      role: RoleType.PARENT,
      statut: StatutUtilisateurType.ACTIF,
      password: 'secret',
    } as Users;

    const parent = {
      user_id: 'u1',
      numero_dossier: '2026-000042',
      user: {
        id: 'u1',
        email: 'p@b.fr',
        prenom: 'Paul',
        nom: 'Parent',
        role: RoleType.PARENT,
        password: 'secret',
      } as Users,
      co_parent: coParent,
      parentChildren: [],
    } as Parents;

    const out = mapParentForApi(parent);
    expect(out.co_parent?.prenom).toBe('Clara');
    expect(out.co_parent?.nom).toBe('Co');
    expect(out.co_parent?.password).toBeUndefined();
    expect(out.user.password).toBeUndefined();
  });
});
