fix(api): eliminate unsafe lint warnings
This commit is contained in:
1 parent
fd1fa2366c
commit
bb68be14fa
12 files changed
+260
-123
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { projectCompetition } from './competition-projector';
|
||||
import {
|
||||
CompetitionDomainError,
|
||||
type CompetitionDomainErrorCode,
|
||||
} from './domain-error';
|
||||
import { generateSeriesGraph } from './series-graph';
|
||||
|
||||
describe('projectCompetition', () => {
|
||||
@@ -323,20 +327,18 @@ describe('projectCompetition', () => {
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, seriesId: 'series-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SERIES_MISMATCH',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, seriesId: 'series-does-not-exist' }],
|
||||
}),
|
||||
'GAME_SERIES_MISMATCH',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -356,20 +358,18 @@ describe('projectCompetition', () => {
|
||||
'team-1',
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, gameSlotId: 'slot-does-not-exist' }],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'GAME_SLOT_INVALID',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [{ ...accepted, gameSlotId: 'slot-does-not-exist' }],
|
||||
}),
|
||||
'GAME_SLOT_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -382,36 +382,34 @@ describe('projectCompetition', () => {
|
||||
};
|
||||
const seriesGraph = generateSeriesGraph({ competitionId, teams, format });
|
||||
|
||||
expect(() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [
|
||||
{
|
||||
id: 'fact-unknown-adjudication-series',
|
||||
type: 'series-adjudicated',
|
||||
competitionId,
|
||||
revision: 1,
|
||||
ordinalWithinRevision: 1,
|
||||
commandId: 'command-unknown-adjudication-series',
|
||||
schemaVersion: 1,
|
||||
actor: { type: 'user' },
|
||||
occurredAt: new Date('2026-07-12T00:00:01.000Z'),
|
||||
recordedAt: new Date('2026-07-12T00:00:02.000Z'),
|
||||
seriesId: 'series-does-not-exist',
|
||||
decision: { type: 'administrative', winnerTeamId: 'team-1' },
|
||||
reason: 'Manual correction',
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'ADJUDICATION_INVALID',
|
||||
}),
|
||||
expectCompetitionDomainError(
|
||||
() =>
|
||||
projectCompetition({
|
||||
competitionId,
|
||||
revision: 1,
|
||||
projectorVersion: 1,
|
||||
teams,
|
||||
format,
|
||||
seriesGraph,
|
||||
facts: [
|
||||
{
|
||||
id: 'fact-unknown-adjudication-series',
|
||||
type: 'series-adjudicated',
|
||||
competitionId,
|
||||
revision: 1,
|
||||
ordinalWithinRevision: 1,
|
||||
commandId: 'command-unknown-adjudication-series',
|
||||
schemaVersion: 1,
|
||||
actor: { type: 'user' },
|
||||
occurredAt: new Date('2026-07-12T00:00:01.000Z'),
|
||||
recordedAt: new Date('2026-07-12T00:00:02.000Z'),
|
||||
seriesId: 'series-does-not-exist',
|
||||
decision: { type: 'administrative', winnerTeamId: 'team-1' },
|
||||
reason: 'Manual correction',
|
||||
},
|
||||
],
|
||||
}),
|
||||
'ADJUDICATION_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -617,3 +615,23 @@ interface GameSlotLike {
|
||||
id: string;
|
||||
ordinal: number;
|
||||
}
|
||||
|
||||
function expectCompetitionDomainError(
|
||||
action: () => unknown,
|
||||
expectedCode: CompetitionDomainErrorCode,
|
||||
): void {
|
||||
let thrown: unknown;
|
||||
try {
|
||||
action();
|
||||
} catch (error: unknown) {
|
||||
thrown = error;
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(CompetitionDomainError);
|
||||
if (!(thrown instanceof CompetitionDomainError)) {
|
||||
throw new Error(
|
||||
`Expected CompetitionDomainError, received ${String(thrown)}`,
|
||||
);
|
||||
}
|
||||
expect(thrown.code).toBe(expectedCode);
|
||||
}
|
||||
Reference in new issue
Block a user