Type the cron registrar stub so the tests typecheck again

typecheck:tests landed with the contract ratchet; the scheduler migration
merged after it, and its idempotency-cleanup test stubs register() with no
parameters. Reading calls[0][2] back off a no-parameter mock types every
recorded call as [], which is a tuple index error, so dev has been red since.
Give the stub the real register() signature and drop the cast it needed.
This commit is contained in:
Maurice
2026-08-11 08:55:15 +02:00
committed by Maurice
parent 8e4261ed81
commit b56dcec118
@@ -64,7 +64,10 @@ describe('IdempotencyCleanupJob', () => {
function makeJob(enabled = true) {
const registrar = {
isEnabled: vi.fn(() => enabled),
register: vi.fn(() => enabled),
// Spelled out rather than vi.fn(() => enabled), because the test below
// reads the third argument back off mock.calls: a no-parameter stub types
// every recorded call as [], and indexing it fails typecheck:tests.
register: vi.fn((_name: string, _expression: string, _onTick: () => void | Promise<void>) => enabled),
unregister: vi.fn(),
};
const job = new IdempotencyCleanupJob(new DatabaseService(db), registrar as unknown as CronRegistrarService);
@@ -78,7 +81,7 @@ describe('IdempotencyCleanupJob', () => {
// The registered callback IS the tick — drive it once over an empty table
// (nothing to purge → no log, no throw).
const onTick = on.registrar.register.mock.calls[0][2] as () => void;
const onTick = on.registrar.register.mock.calls[0][2];
expect(() => onTick()).not.toThrow();
const off = makeJob(false);