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

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

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

  describe('present', () => {
    it('should present total leagues count', () => {
      presenter.present({ totalLeagues: 42 });

      const vm = presenter.getResponseModel();

      expect(vm).toEqual({
        totalLeagues: 42,
      });
    });

    it('should present zero total leagues', () => {
      presenter.present({ totalLeagues: 0 });

      const vm = presenter.getResponseModel();

      expect(vm).toEqual({
        totalLeagues: 0,
      });
    });

    it('should present large total leagues count', () => {
      presenter.present({ totalLeagues: 999999 });

      const vm = presenter.getResponseModel();

      expect(vm).toEqual({
        totalLeagues: 999999,
      });
    });
  });

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

    it('should return the model after presentation', () => {
      presenter.present({ totalLeagues: 10 });

      expect(presenter.getResponseModel()).toEqual({
        totalLeagues: 10,
      });
    });
  });

  describe('reset', () => {
    it('should reset the model to null', () => {
      presenter.present({ totalLeagues: 25 });
      expect(presenter.getResponseModel()).not.toBeNull();

      presenter.reset();

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