29 lines
804 B
TypeScript
29 lines
804 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { RaceStatsDTO } from '../types/generated/RaceStatsDTO';
|
|
import { RaceStatsViewModel } from './RaceStatsViewModel';
|
|
|
|
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());
|
|
});
|
|
});
|