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