import { describe, it, expect } from 'vitest';
import { LeagueAdminViewModel } from './LeagueAdminViewModel';
import type { LeagueMemberViewModel } from './LeagueMemberViewModel';
import type { LeagueJoinRequestViewModel } from './LeagueJoinRequestViewModel';

describe('LeagueAdminViewModel', () => {
  it('should create instance with all properties', () => {
    const members: LeagueMemberViewModel[] = [];
    const joinRequests: LeagueJoinRequestViewModel[] = [];
    const dto = {
      config: { name: 'Test League' },
      members,
      joinRequests,
    };

    const viewModel = new LeagueAdminViewModel(dto);

    expect(viewModel.config).toEqual({ name: 'Test League' });
    expect(viewModel.members).toBe(members);
    expect(viewModel.joinRequests).toBe(joinRequests);
  });

  it('should return correct pending requests count when empty', () => {
    const viewModel = new LeagueAdminViewModel({
      config: {},
      members: [],
      joinRequests: [],
    });

    expect(viewModel.pendingRequestsCount).toBe(0);
  });

  it('should return correct pending requests count with requests', () => {
    const joinRequests = [
      {} as LeagueJoinRequestViewModel,
      {} as LeagueJoinRequestViewModel,
      {} as LeagueJoinRequestViewModel,
    ];
    const viewModel = new LeagueAdminViewModel({
      config: {},
      members: [],
      joinRequests,
    });

    expect(viewModel.pendingRequestsCount).toBe(3);
  });

  it('should return false for hasPendingRequests when empty', () => {
    const viewModel = new LeagueAdminViewModel({
      config: {},
      members: [],
      joinRequests: [],
    });

    expect(viewModel.hasPendingRequests).toBe(false);
  });

  it('should return true for hasPendingRequests when requests exist', () => {
    const viewModel = new LeagueAdminViewModel({
      config: {},
      members: [],
      joinRequests: [{} as LeagueJoinRequestViewModel],
    });

    expect(viewModel.hasPendingRequests).toBe(true);
  });
});