wip league admin tools
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { LeagueScoringChampionshipViewModel } from './LeagueScoringChampionshipViewModel';
|
||||
|
||||
describe('LeagueScoringChampionshipViewModel', () => {
|
||||
it('exposes required fields from input', () => {
|
||||
const input = {
|
||||
id: 'champ-1',
|
||||
name: 'Drivers',
|
||||
type: 'driver',
|
||||
sessionTypes: ['race'],
|
||||
pointsPreview: [{ sessionType: 'race', position: 1, points: 25 }],
|
||||
bonusSummary: ['Pole: +1'],
|
||||
dropPolicyDescription: 'Best 6 of 8',
|
||||
};
|
||||
|
||||
const vm = new LeagueScoringChampionshipViewModel(input);
|
||||
|
||||
expect(vm.id).toBe('champ-1');
|
||||
expect(vm.name).toBe('Drivers');
|
||||
expect(vm.type).toBe('driver');
|
||||
expect(vm.sessionTypes).toEqual(['race']);
|
||||
expect(vm.pointsPreview).toEqual([{ sessionType: 'race', position: 1, points: 25 }]);
|
||||
expect(vm.bonusSummary).toEqual(['Pole: +1']);
|
||||
expect(vm.dropPolicyDescription).toBe('Best 6 of 8');
|
||||
|
||||
expect(typeof vm.id).toBe('string');
|
||||
expect(typeof vm.name).toBe('string');
|
||||
expect(typeof vm.type).toBe('string');
|
||||
expect(Array.isArray(vm.sessionTypes)).toBe(true);
|
||||
expect(Array.isArray(vm.pointsPreview)).toBe(true);
|
||||
expect(Array.isArray(vm.bonusSummary)).toBe(true);
|
||||
});
|
||||
|
||||
it('defaults optional extended fields deterministically', () => {
|
||||
const input = {
|
||||
id: 'champ-1',
|
||||
name: 'Drivers',
|
||||
type: 'driver',
|
||||
sessionTypes: ['race'],
|
||||
pointsPreview: undefined,
|
||||
};
|
||||
|
||||
const vm = new LeagueScoringChampionshipViewModel(input);
|
||||
|
||||
expect(vm.pointsPreview).toEqual([]);
|
||||
expect(vm.bonusSummary).toEqual([]);
|
||||
expect(vm.dropPolicyDescription).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user