import { ForgotPasswordPresenter } from './ForgotPasswordPresenter';

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

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

  describe('present', () => {
    it('should map result to response model', () => {
      const result = { message: 'Password reset link generated successfully', magicLink: 'http://example.com/reset?token=abc123' };

      presenter.present(result);

      expect(presenter.responseModel).toEqual({ message: 'Password reset link generated successfully', magicLink: 'http://example.com/reset?token=abc123' });
    });

    it('should handle result without magicLink', () => {
      const result = { message: 'If an account exists with this email, a password reset link will be sent', magicLink: null };

      presenter.present(result);

      expect(presenter.responseModel).toEqual({ message: 'If an account exists with this email, a password reset link will be sent', magicLink: null });
    });
  });

  describe('reset', () => {
    it('should clear the response model', () => {
      presenter.present({ message: 'Password reset link generated successfully', magicLink: 'http://example.com' });
      expect(presenter.responseModel).toBeDefined();

      presenter.reset();
      expect(() => presenter.responseModel).toThrow('ForgotPasswordPresenter: No response model available');
    });
  });

  describe('responseModel', () => {
    it('should throw error when accessed before present()', () => {
      expect(() => presenter.responseModel).toThrow('ForgotPasswordPresenter: No response model available');
    });
  });
});