view models
This commit is contained in:
28
apps/website/lib/view-models/RaceStatsViewModel.test.ts
Normal file
28
apps/website/lib/view-models/RaceStatsViewModel.test.ts
Normal 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());
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user