import { describe, it, expect } from 'vitest';
import { SponsorshipDetailViewModel } from './SponsorshipDetailViewModel';

describe('SponsorshipDetailViewModel', () => {
  const dto = {
    id: 'detail-1',
    leagueId: 'league-1',
    leagueName: 'Pro League',
    seasonId: 'season-1',
    seasonName: 'Season 1',
  } as any;

  it('maps core identifiers from generated DTO', () => {
    const vm = new SponsorshipDetailViewModel(dto);

    expect(vm.id).toBe(dto.id);
    expect(vm.leagueId).toBe(dto.leagueId);
    expect(vm.leagueName).toBe(dto.leagueName);
    expect(vm.seasonId).toBe(dto.seasonId);
    expect(vm.seasonName).toBe(dto.seasonName);
  });

  it('uses default UI-specific sponsorship fields and formatting', () => {
    const vm = new SponsorshipDetailViewModel(dto);

    expect(vm.tier).toBe('secondary');
    expect(vm.status).toBe('active');
    expect(vm.amount).toBe(0);
    expect(vm.currency).toBe('USD');

    expect(vm.formattedAmount).toBe('USD 0');
    expect(vm.tierBadgeVariant).toBe('secondary');
    expect(vm.statusColor).toBe('green');
    expect(vm.statusDisplay).toBe('Active');
  });

  it('derives badge variant and status styling from status and tier', () => {
    const main = new SponsorshipDetailViewModel(dto);
    main.tier = 'main';
    main.status = 'pending';
    main.amount = 5_000;

    expect(main.tierBadgeVariant).toBe('primary');
    expect(main.statusColor).toBe('yellow');
    expect(main.statusDisplay).toBe('Pending');
    expect(main.formattedAmount).toBe('USD 5,000');

    const expired = new SponsorshipDetailViewModel(dto);
    expired.status = 'expired';
    expect(expired.statusColor).toBe('red');

    const unknown = new SponsorshipDetailViewModel(dto);
    unknown.status = 'unknown' as any;
    expect(unknown.statusColor).toBe('gray');
  });
});
