import { GetAvatarPresenter } from './GetAvatarPresenter';

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

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

  describe('transform', () => {
    it('should map result to response model', () => {
      const result = {
        avatar: {
          id: 'avatar-123',
          driverId: 'driver-456',
          mediaUrl: 'https://example.com/avatar.png',
          selectedAt: new Date('2024-01-01'),
        },
      };

      const response = presenter.transform(result);

      expect(response).toEqual({ avatarUrl: 'https://example.com/avatar.png' });
      expect(presenter.getResponseModel()).toEqual({ avatarUrl: 'https://example.com/avatar.png' });
    });

    it('should handle different avatar URLs', () => {
      const result = {
        avatar: {
          id: 'avatar-789',
          driverId: 'driver-456',
          mediaUrl: 'https://cdn.example.com/avatars/test.jpg',
          selectedAt: new Date('2024-01-02'),
        },
      };

      const response = presenter.transform(result);

      expect(response).toEqual({ avatarUrl: 'https://cdn.example.com/avatars/test.jpg' });
    });
  });

  describe('reset', () => {
    it('should clear the model', () => {
      presenter.transform({
        avatar: {
          id: 'avatar-123',
          driverId: 'driver-456',
          mediaUrl: 'https://example.com/avatar.png',
          selectedAt: new Date('2024-01-01'),
        },
      });
      expect(presenter.getResponseModel()).not.toBeNull();

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

  describe('responseModel', () => {
    it('should return null when model is null', () => {
      expect(presenter.responseModel).toBeNull();
    });

    it('should return model after transform()', () => {
      presenter.transform({
        avatar: {
          id: 'avatar-123',
          driverId: 'driver-456',
          mediaUrl: 'https://example.com/avatar.png',
          selectedAt: new Date('2024-01-01'),
        },
      });
      expect(presenter.responseModel).toEqual({ avatarUrl: 'https://example.com/avatar.png' });
    });
  });

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

    it('should return model after transform()', () => {
      presenter.transform({
        avatar: {
          id: 'avatar-123',
          driverId: 'driver-456',
          mediaUrl: 'https://example.com/avatar.png',
          selectedAt: new Date('2024-01-01'),
        },
      });
      expect(presenter.getResponseModel()).toEqual({ avatarUrl: 'https://example.com/avatar.png' });
    });
  });
});