import { CreateTeamPresenter } from './CreateTeamPresenter';

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

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

  describe('present', () => {
    it('should map result to response model', () => {
      const result = {
        team: {
          id: 'team-123',
        } as never,
      };

      presenter.present(result);

      expect(presenter.responseModel).toEqual({
        id: 'team-123',
        success: true,
      });
    });

    it('should handle different team IDs', () => {
      const result = {
        team: {
          id: 'team-456',
        } as never,
      };

      presenter.present(result);

      expect(presenter.responseModel).toEqual({
        id: 'team-456',
        success: true,
      });
    });
  });

  describe('reset', () => {
    it('should clear the model', () => {
      presenter.present({ team: { id: 'team-123' } } as never);
      expect(presenter.responseModel).toBeDefined();

      presenter.reset();
      expect(presenter.getResponseModel()).toBeNull();
    });
  });

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

    it('should return model after present()', () => {
      presenter.present({ team: { id: 'team-123' } } as never);
      expect(presenter.getResponseModel()).toEqual({
        id: 'team-123',
        success: true,
      });
    });
  });

  describe('responseModel', () => {
    it('should throw error when accessed before present()', () => {
      expect(() => presenter.responseModel).toThrow('Presenter not presented');
    });

    it('should return model after present()', () => {
      presenter.present({ team: { id: 'team-123' } } as never);
      expect(presenter.responseModel).toEqual({
        id: 'team-123',
        success: true,
      });
    });
  });
});