module cleanup
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { GetSponsorsPresenter } from './GetSponsorsPresenter';
|
||||
|
||||
describe('GetSponsorsPresenter', () => {
|
||||
let presenter: GetSponsorsPresenter;
|
||||
|
||||
beforeEach(() => {
|
||||
presenter = new GetSponsorsPresenter();
|
||||
});
|
||||
|
||||
describe('reset', () => {
|
||||
it('should reset the result to null', () => {
|
||||
const mockResult = { sponsors: [] };
|
||||
presenter.present(mockResult);
|
||||
expect(presenter.viewModel).toEqual(mockResult);
|
||||
|
||||
presenter.reset();
|
||||
expect(() => presenter.viewModel).toThrow('Presenter not presented');
|
||||
});
|
||||
});
|
||||
|
||||
describe('present', () => {
|
||||
it('should store the result', () => {
|
||||
const mockResult = {
|
||||
sponsors: [
|
||||
{ id: 'sponsor-1', name: 'Sponsor One', contactEmail: 's1@example.com' },
|
||||
{ id: 'sponsor-2', name: 'Sponsor Two', contactEmail: 's2@example.com' },
|
||||
],
|
||||
};
|
||||
|
||||
presenter.present(mockResult);
|
||||
|
||||
expect(presenter.viewModel).toEqual(mockResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getViewModel', () => {
|
||||
it('should return null when not presented', () => {
|
||||
expect(presenter.getViewModel()).toBeNull();
|
||||
});
|
||||
|
||||
it('should return the result when presented', () => {
|
||||
const mockResult = { sponsors: [] };
|
||||
presenter.present(mockResult);
|
||||
|
||||
expect(presenter.getViewModel()).toEqual(mockResult);
|
||||
});
|
||||
});
|
||||
|
||||
describe('viewModel', () => {
|
||||
it('should throw error when not presented', () => {
|
||||
expect(() => presenter.viewModel).toThrow('Presenter not presented');
|
||||
});
|
||||
|
||||
it('should return the result when presented', () => {
|
||||
const mockResult = { sponsors: [] };
|
||||
presenter.present(mockResult);
|
||||
|
||||
expect(presenter.viewModel).toEqual(mockResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user