import { UpdateAvatarPresenter } from './UpdateAvatarPresenter';

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

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

  describe('transform', () => {
    it('should map result to response model', () => {
      const result = {
        avatarId: 'avatar-123',
        driverId: 'driver-456',
      };

      const response = presenter.transform(result);

      expect(response).toEqual({ success: true });
      expect(presenter.getResponseModel()).toEqual({ success: true });
    });

    it('should always return success true', () => {
      const result = {
        avatarId: 'avatar-789',
        driverId: 'driver-999',
      };

      const response = presenter.transform(result);

      expect(response.success).toBe(true);
    });
  });

  describe('reset', () => {
    it('should clear the model', () => {
      presenter.transform({ avatarId: 'avatar-123', driverId: 'driver-456' });
      expect(presenter.getResponseModel()).not.toBeNull();

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

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

    it('should return model after transform()', () => {
      presenter.transform({ avatarId: 'avatar-123', driverId: 'driver-456' });
      expect(presenter.responseModel).toEqual({ success: true });
    });
  });

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

    it('should return model after transform()', () => {
      presenter.transform({ avatarId: 'avatar-123', driverId: 'driver-456' });
      expect(presenter.getResponseModel()).toEqual({ success: true });
    });
  });
});