fix(companion): validate runtime and heartbeat loop options
This commit is contained in:
@@ -37,6 +37,16 @@ describe('CompanionHeartbeatLoop', () => {
|
||||
loop.stop();
|
||||
});
|
||||
|
||||
it('validates constructor options', () => {
|
||||
const publisher = { publishHeartbeat: vi.fn(async () => buildStatusResult()) };
|
||||
expect(() => new CompanionHeartbeatLoop(publisher, { intervalMs: 0 })).toThrow(
|
||||
'intervalMs must be a positive number',
|
||||
);
|
||||
expect(() => new CompanionHeartbeatLoop(publisher, { maxConsecutiveFailures: 0 })).toThrow(
|
||||
'maxConsecutiveFailures must be >= 1 when specified',
|
||||
);
|
||||
});
|
||||
|
||||
it('supports delayed first run when runImmediately=false', async () => {
|
||||
const publishHeartbeat = vi.fn(async () => buildStatusResult());
|
||||
const loop = new CompanionHeartbeatLoop({ publishHeartbeat }, { intervalMs: 500 });
|
||||
|
||||
Reference in New Issue
Block a user