feat: unify competition schedule and results
This commit is contained in:
1 parent
4e10998794
commit
c9140b8622
12 files changed
+910
-245
No files matched your search
@@ -1,6 +1,110 @@
|
||||
import { projectSeries } from './series-projector';
|
||||
|
||||
describe('projectSeries', () => {
|
||||
it.each([
|
||||
['a known local time', '21:30'],
|
||||
['an unknown local time', null],
|
||||
] as const)('preserves an optional Series schedule with %s', (_, time) => {
|
||||
const schedule = {
|
||||
date: '2026-07-15',
|
||||
time,
|
||||
timeZone: 'Asia/Seoul' as const,
|
||||
};
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: `series-scheduled-${time ?? 'unknown'}`,
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
};
|
||||
|
||||
const projection = projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
});
|
||||
|
||||
expect(projection).toMatchObject({
|
||||
status: 'ready',
|
||||
schedule,
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps an existing definition without a schedule explicitly unscheduled', () => {
|
||||
const definition = seriesDefinition({
|
||||
id: 'series-unscheduled',
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to', winsRequired: 1, maxGames: 1 },
|
||||
});
|
||||
|
||||
const projection = projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
});
|
||||
|
||||
expect(projection).not.toHaveProperty('schedule');
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'an impossible calendar date',
|
||||
{ date: '2026-02-30', time: '21:30', timeZone: 'Asia/Seoul' },
|
||||
],
|
||||
[
|
||||
'an out-of-range local time',
|
||||
{ date: '2026-07-15', time: '24:00', timeZone: 'Asia/Seoul' },
|
||||
],
|
||||
[
|
||||
'a non-canonical time zone',
|
||||
{ date: '2026-07-15', time: '21:30', timeZone: 'UTC' },
|
||||
],
|
||||
])('rejects a Series schedule with %s', (_, schedule) => {
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: `series-invalid-schedule-${schedule.date}-${schedule.time}`,
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||
|
||||
expectInvariant(
|
||||
() =>
|
||||
projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
}),
|
||||
'SERIES_DEFINITION_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
it.each([null, false, ''])(
|
||||
'rejects a non-object Series schedule value %p',
|
||||
(schedule) => {
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: 'series-invalid-schedule-shape',
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||
|
||||
expectInvariant(
|
||||
() =>
|
||||
projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
}),
|
||||
'SERIES_DEFINITION_INVALID',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps a fixed-games pair in progress until every game slot is filled', () => {
|
||||
const definition = seriesDefinition({
|
||||
id: 'series-pair',
|
||||
|
||||
Reference in new issue
Block a user