view models
This commit is contained in:
34
apps/website/lib/view-models/LeagueStatsViewModel.test.ts
Normal file
34
apps/website/lib/view-models/LeagueStatsViewModel.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { LeagueStatsViewModel } from './LeagueStatsViewModel';
|
||||
|
||||
const createDto = (overrides: Partial<{ totalLeagues: number }> = {}): { totalLeagues: number } => ({
|
||||
totalLeagues: 1234,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
describe('LeagueStatsViewModel', () => {
|
||||
it('maps totalLeagues from DTO', () => {
|
||||
const dto = createDto({ totalLeagues: 42 });
|
||||
|
||||
const vm = new LeagueStatsViewModel(dto);
|
||||
|
||||
expect(vm.totalLeagues).toBe(42);
|
||||
});
|
||||
|
||||
it('formats totalLeagues using locale separators', () => {
|
||||
const dto = createDto({ totalLeagues: 12345 });
|
||||
|
||||
const vm = new LeagueStatsViewModel(dto);
|
||||
|
||||
expect(vm.formattedTotalLeagues).toBe((12345).toLocaleString());
|
||||
});
|
||||
|
||||
it('handles zero leagues correctly', () => {
|
||||
const dto = createDto({ totalLeagues: 0 });
|
||||
|
||||
const vm = new LeagueStatsViewModel(dto);
|
||||
|
||||
expect(vm.totalLeagues).toBe(0);
|
||||
expect(vm.formattedTotalLeagues).toBe('0');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user