presenter refactoring

This commit is contained in:
2025-12-20 17:06:11 +01:00
parent 92be9d2e1b
commit e9d6f90bb2
109 changed files with 4159 additions and 1283 deletions

View File

@@ -0,0 +1,45 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { GetDashboardDataPresenter } from './GetDashboardDataPresenter';
import type { GetDashboardDataOutput } from '@core/analytics/application/use-cases/GetDashboardDataUseCase';
describe('GetDashboardDataPresenter', () => {
let presenter: GetDashboardDataPresenter;
beforeEach(() => {
presenter = new GetDashboardDataPresenter();
});
it('maps use case output to DTO correctly', () => {
const output: GetDashboardDataOutput = {
totalUsers: 100,
activeUsers: 50,
totalRaces: 20,
totalLeagues: 5,
};
presenter.present(output);
expect(presenter.viewModel).toEqual({
totalUsers: 100,
activeUsers: 50,
totalRaces: 20,
totalLeagues: 5,
});
});
it('reset clears state and causes viewModel to throw', () => {
const output: GetDashboardDataOutput = {
totalUsers: 100,
activeUsers: 50,
totalRaces: 20,
totalLeagues: 5,
};
presenter.present(output);
expect(presenter.viewModel).toBeDefined();
presenter.reset();
expect(() => presenter.viewModel).toThrow('Presenter not presented');
});
});