view models
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { LeagueScoringPresetsViewModel } from './LeagueScoringPresetsViewModel';
|
||||
import type { LeagueScoringPresetDTO } from '@core/racing/application/ports/LeagueScoringPresetProvider';
|
||||
|
||||
const createPreset = (overrides: Partial<LeagueScoringPresetDTO> = {}): LeagueScoringPresetDTO => ({
|
||||
id: 'preset-1',
|
||||
name: 'Standard scoring',
|
||||
description: 'Top 15 get points',
|
||||
gameId: 'iracing',
|
||||
...overrides,
|
||||
} as LeagueScoringPresetDTO);
|
||||
|
||||
describe('LeagueScoringPresetsViewModel', () => {
|
||||
it('maps presets array from DTO', () => {
|
||||
const presets = [createPreset(), createPreset({ id: 'preset-2', name: 'Alt scoring' })];
|
||||
|
||||
const vm = new LeagueScoringPresetsViewModel({ presets });
|
||||
|
||||
expect(vm.presets).toBe(presets);
|
||||
expect(vm.totalCount).toBe(2);
|
||||
});
|
||||
|
||||
it('uses explicit totalCount when provided', () => {
|
||||
const presets = [createPreset(), createPreset()];
|
||||
|
||||
const vm = new LeagueScoringPresetsViewModel({ presets, totalCount: 10 });
|
||||
|
||||
expect(vm.presets).toBe(presets);
|
||||
expect(vm.totalCount).toBe(10);
|
||||
});
|
||||
|
||||
it('handles empty presets array', () => {
|
||||
const vm = new LeagueScoringPresetsViewModel({ presets: [] });
|
||||
|
||||
expect(vm.presets).toEqual([]);
|
||||
expect(vm.totalCount).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user