This commit is contained in:
2026-01-08 17:36:08 +01:00
parent 66ec6fe727
commit 05cf3bafd2
23 changed files with 3004 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
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');
});
});
});

View File

@@ -0,0 +1,43 @@
import { ResetPasswordPresenter } from './ResetPasswordPresenter';
describe('ResetPasswordPresenter', () => {
let presenter: ResetPasswordPresenter;
beforeEach(() => {
presenter = new ResetPasswordPresenter();
});
describe('present', () => {
it('should map result to response model', () => {
const result = { message: 'Password reset successfully. You can now log in with your new password.' };
presenter.present(result);
expect(presenter.responseModel).toEqual({ message: 'Password reset successfully. You can now log in with your new password.' });
});
it('should handle different message', () => {
const result = { message: 'Password updated' };
presenter.present(result);
expect(presenter.responseModel).toEqual({ message: 'Password updated' });
});
});
describe('reset', () => {
it('should clear the response model', () => {
presenter.present({ message: 'Password reset successfully' });
expect(presenter.responseModel).toBeDefined();
presenter.reset();
expect(() => presenter.responseModel).toThrow('ResetPasswordPresenter: No response model available');
});
});
describe('responseModel', () => {
it('should throw error when accessed before present()', () => {
expect(() => presenter.responseModel).toThrow('ResetPasswordPresenter: No response model available');
});
});
});