tests
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user