35 lines
957 B
TypeScript
35 lines
957 B
TypeScript
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');
|
|
});
|
|
});
|