test: harden competition migration assertions

This commit is contained in:
dahyeon committed 2026-07-13 03:59:52 +00:00
1 parent a307780752
commit bbcb2f43dc
2 files changed
+72 -71

No files matched your search

@@ -210,9 +210,7 @@ describe('generateSeriesGraph', () => {
pairing(1, 2, 'team-3', 'team-4'),
]);
expect(() => generateSeriesGraph(input)).toThrow(
expect.objectContaining({ code: 'INVALID_ROUND_ROBIN_PAIRING' }),
);
expectGraphError(input, 'INVALID_ROUND_ROBIN_PAIRING');
},
);
@@ -234,9 +232,7 @@ describe('generateSeriesGraph', () => {
code: 'DUPLICATE_ROUND_ROBIN_OPPONENTS',
},
])('rejects a duplicate explicit $name', ({ pairings, code }) => {
expect(() =>
generateSeriesGraph(explicitRoundRobinInput(pairings)),
).toThrow(expect.objectContaining({ code }));
expectGraphError(explicitRoundRobinInput(pairings), code);
});
});
@@ -244,6 +240,15 @@ function firstTo(winsRequired: number, maxGames: number) {
return { type: 'first-to' as const, winsRequired, maxGames };
}
function expectGraphError(input: GraphInput, code: string): void {
try {
generateSeriesGraph(input);
throw new Error(`Expected graph error ${code}.`);
} catch (error) {
expect(error).toMatchObject({ code });
}
}
function fixedGames(gameCount: number) {
return {
type: 'fixed-games' as const,