feat(companion): add platform createHeartbeatLoop helper
This commit is contained in:
@@ -223,4 +223,19 @@ describe('platform companion clients', () => {
|
||||
'sessionId is required (provide one or configure defaultSessionId)',
|
||||
);
|
||||
});
|
||||
|
||||
it('creates a bound heartbeat loop helper from platform clients', async () => {
|
||||
const mock = createRuntimeMock();
|
||||
const client = new IOSCompanionClient({ runtime: mock.runtime, nodeId: 'ios-node' });
|
||||
|
||||
const loop = client.createHeartbeatLoop();
|
||||
await loop.tickNow();
|
||||
|
||||
expect(mock.setNodeStatus).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
platform: 'ios',
|
||||
statusText: 'heartbeat',
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,12 @@ import type {
|
||||
SystemCapabilitiesResult,
|
||||
SystemNodesResult,
|
||||
} from './runtimeClient.js';
|
||||
import {
|
||||
CompanionHeartbeatLoop,
|
||||
} from './heartbeatLoop.js';
|
||||
import type {
|
||||
CompanionHeartbeatLoopOptions,
|
||||
} from './heartbeatLoop.js';
|
||||
|
||||
export interface PlatformClientOptions {
|
||||
runtime: CompanionRuntimeClient;
|
||||
@@ -129,6 +135,10 @@ export class MacOSCompanionClient {
|
||||
});
|
||||
}
|
||||
|
||||
createHeartbeatLoop(options: CompanionHeartbeatLoopOptions = {}): CompanionHeartbeatLoop {
|
||||
return new CompanionHeartbeatLoop(this, options);
|
||||
}
|
||||
|
||||
setLocation(location: SetNodeLocationInput): Promise<NodeLocationSetResult> {
|
||||
return this.runtime.setNodeLocation(location);
|
||||
}
|
||||
@@ -261,6 +271,10 @@ export class IOSCompanionClient {
|
||||
});
|
||||
}
|
||||
|
||||
createHeartbeatLoop(options: CompanionHeartbeatLoopOptions = {}): CompanionHeartbeatLoop {
|
||||
return new CompanionHeartbeatLoop(this, options);
|
||||
}
|
||||
|
||||
setLocation(location: SetNodeLocationInput): Promise<NodeLocationSetResult> {
|
||||
return this.runtime.setNodeLocation(location);
|
||||
}
|
||||
@@ -393,6 +407,10 @@ export class AndroidCompanionClient {
|
||||
});
|
||||
}
|
||||
|
||||
createHeartbeatLoop(options: CompanionHeartbeatLoopOptions = {}): CompanionHeartbeatLoop {
|
||||
return new CompanionHeartbeatLoop(this, options);
|
||||
}
|
||||
|
||||
setLocation(location: SetNodeLocationInput): Promise<NodeLocationSetResult> {
|
||||
return this.runtime.setNodeLocation(location);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user