wip league admin tools
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { LeagueAdminScheduleViewModel } from './LeagueAdminScheduleViewModel';
|
||||
import type { LeagueScheduleRaceViewModel } from './LeagueScheduleViewModel';
|
||||
|
||||
describe('LeagueAdminScheduleViewModel', () => {
|
||||
it('exposes seasonId/published/races from constructor input', () => {
|
||||
const races: LeagueScheduleRaceViewModel[] = [
|
||||
{
|
||||
id: 'race-1',
|
||||
name: 'Round 1',
|
||||
scheduledAt: new Date('2025-01-02T20:00:00Z'),
|
||||
isPast: false,
|
||||
isUpcoming: true,
|
||||
status: 'scheduled',
|
||||
},
|
||||
];
|
||||
|
||||
const vm = new LeagueAdminScheduleViewModel({
|
||||
seasonId: 'season-1',
|
||||
published: true,
|
||||
races,
|
||||
});
|
||||
|
||||
expect(vm.seasonId).toBe('season-1');
|
||||
expect(vm.published).toBe(true);
|
||||
expect(vm.races).toBe(races);
|
||||
expect(vm.races).toHaveLength(1);
|
||||
|
||||
expect(typeof vm.seasonId).toBe('string');
|
||||
expect(typeof vm.published).toBe('boolean');
|
||||
expect(vm.races[0]?.scheduledAt).toBeInstanceOf(Date);
|
||||
});
|
||||
|
||||
it('keeps published as a boolean even when false', () => {
|
||||
const vm = new LeagueAdminScheduleViewModel({
|
||||
seasonId: 'season-1',
|
||||
published: false,
|
||||
races: [],
|
||||
});
|
||||
|
||||
expect(vm.published).toBe(false);
|
||||
expect(typeof vm.published).toBe('boolean');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user