import { describe, it, expect } from 'vitest';
import { TeamCardViewModel } from './TeamCardViewModel';
import type { TeamListItemDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';

const createTeamCardDto = (): { id: string; name: string; tag: string; description: string } => ({
  id: 'team-1',
  name: 'Team Alpha',
  tag: 'ALPHA',
  description: 'Endurance specialists',
});

const createTeamListItemDto = (overrides: Partial<TeamListItemDTO> = {}): TeamListItemDTO => ({
  id: 'team-2',
  name: 'Team Beta',
  tag: 'BETA',
  description: 'A test team',
  memberCount: 5,
  leagues: ['league-1'],
  ...overrides,
});

describe('TeamCardViewModel', () => {
  it('maps fields from simple TeamCardDTO', () => {
    const dto = createTeamCardDto();

    const vm = new TeamCardViewModel(dto);

    expect(vm.id).toBe('team-1');
    expect(vm.name).toBe('Team Alpha');
    expect(vm.tag).toBe('ALPHA');
    expect(vm.description).toBe('Endurance specialists');
  });

  it('maps fields from TeamListItemDTO', () => {
    const dto = createTeamListItemDto({ id: 'team-123', name: 'Custom Team', tag: 'CT' });

    const vm = new TeamCardViewModel(dto);

    expect(vm.id).toBe('team-123');
    expect(vm.name).toBe('Custom Team');
    expect(vm.tag).toBe('CT');
    expect(vm.description).toBe('A test team');
  });
});
