view models

This commit is contained in:
2025-12-20 00:31:31 +01:00
parent 5c74837d73
commit 656ec62426
74 changed files with 4511 additions and 347 deletions

View File

@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest';
import { RaceStatsViewModel } from './RaceStatsViewModel';
import type { RaceStatsDTO } from '../types/generated';
const createDto = (overrides: Partial<RaceStatsDTO> = {}): RaceStatsDTO => ({
totalRaces: 1234,
...overrides,
});
describe('RaceStatsViewModel', () => {
it('maps totalRaces from DTO', () => {
const dto = createDto({ totalRaces: 42 });
const viewModel = new RaceStatsViewModel(dto);
expect(viewModel.totalRaces).toBe(42);
});
it('formats totalRaces with locale separators', () => {
const dto = createDto({ totalRaces: 12345 });
const viewModel = new RaceStatsViewModel(dto);
const formatted = viewModel.formattedTotalRaces;
expect(formatted).toBe((12345).toLocaleString());
});
});