import { describe, it, expect, beforeEach, vi, Mock } from 'vitest';
import { RejectTeamJoinRequestUseCase } from './RejectTeamJoinRequestUseCase';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';

describe('RejectTeamJoinRequestUseCase', () => {
  let useCase: RejectTeamJoinRequestUseCase;
  let membershipRepository: { removeJoinRequest: Mock };

  beforeEach(() => {
    membershipRepository = { removeJoinRequest: vi.fn() };
    useCase = new RejectTeamJoinRequestUseCase(
      membershipRepository as unknown as ITeamMembershipRepository,
    );
  });

  it('should reject the join request successfully', async () => {
    membershipRepository.removeJoinRequest.mockResolvedValue(undefined);

    const result = await useCase.execute({
      requestId: 'request-1',
    });

    expect(result.isOk()).toBe(true);
    expect(result.unwrap()).toBeUndefined();
    expect(membershipRepository.removeJoinRequest).toHaveBeenCalledWith('request-1');
  });
});