fix: reject unfinishable first-to rules
This commit is contained in:
1 parent
0c2c7b59fc
commit
78a2c7cf0d
4 files changed
+47
-5
No files matched your search
@@ -86,6 +86,32 @@ describe('generateSeriesGraph', () => {
|
||||
expect(series).not.toHaveProperty('loserAdvancesTo');
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects a first-to rule that can exhaust every GameSlot without a winner', () => {
|
||||
try {
|
||||
generateSeriesGraph({
|
||||
competitionId: 'competition-unfinishable-first-to',
|
||||
teams: Array.from({ length: 4 }, (_, index) => ({
|
||||
teamId: `team-${index + 1}`,
|
||||
displayOrder: index + 1,
|
||||
seedNumber: index + 1,
|
||||
})),
|
||||
format: {
|
||||
type: 'double-elimination',
|
||||
resetFinalEnabled: false,
|
||||
rules: {
|
||||
upper: firstTo(2, 2),
|
||||
lower: firstTo(1, 1),
|
||||
grandFinal: firstTo(1, 1),
|
||||
resetFinal: firstTo(1, 1),
|
||||
},
|
||||
},
|
||||
});
|
||||
throw new Error('Expected INVALID_FIRST_TO_RULE');
|
||||
} catch (error) {
|
||||
expect(error).toMatchObject({ code: 'INVALID_FIRST_TO_RULE' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function firstTo(winsRequired: number, maxGames: number) {
|
||||
|
||||
Reference in new issue
Block a user