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

describe('ApproveLeagueJoinRequestPresenter', () => {
  let presenter: ApproveLeagueJoinRequestPresenter;

  beforeEach(() => {
    presenter = new ApproveLeagueJoinRequestPresenter();
  });

  describe('present', () => {
    it('should present successful approval result', () => {
      const result = {
        success: true,
        message: 'Join request approved successfully',
      };

      presenter.present(result);

      const vm = presenter.getViewModel();

      expect(vm).toEqual({
        success: true,
        message: 'Join request approved successfully',
      });
    });

    it('should present failed approval result', () => {
      const result = {
        success: false,
        message: 'Failed to approve join request',
      };

      presenter.present(result);

      const vm = presenter.getViewModel();

      expect(vm).toEqual({
        success: false,
        message: 'Failed to approve join request',
      });
    });

    it('should handle empty message', () => {
      const result = {
        success: true,
        message: '',
      };

      presenter.present(result);

      const vm = presenter.getViewModel();

      expect(vm).toEqual({
        success: true,
        message: '',
      });
    });
  });

  describe('getViewModel', () => {
    it('should return null before presentation', () => {
      expect(presenter.getViewModel()).toBeNull();
    });

    it('should return the model after presentation', () => {
      presenter.present({ success: true, message: 'Test' });

      expect(presenter.getViewModel()).toEqual({
        success: true,
        message: 'Test',
      });
    });
  });

  describe('reset', () => {
    it('should reset the model to null', () => {
      presenter.present({ success: true, message: 'Test' });
      expect(presenter.getViewModel()).not.toBeNull();

      presenter.reset();

      expect(presenter.getViewModel()).toBeNull();
    });
  });
});