activeClient = client
const budget = timeoutMs ?? UI_WEBSOCKET_REQUEST_TIMEOUT_MS
+ if (!Number.isFinite(budget) || budget <= 0) {
+ throw new Error(`Invalid timeout: ${String(budget)}ms (must be > 0)`)
+ }
const startTime = Date.now()
let connectTimeoutId: ReturnType<typeof setTimeout> | undefined
await it('should export executeCommand function', () => {
assert.strictEqual(typeof executeCommand, 'function')
})
+
+ await it('should reject executeCommand with NaN timeout', async () => {
+ await assert.rejects(
+ executeCommand({
+ config: { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' },
+ formatter: { error: () => undefined, output: () => undefined },
+ payload: {},
+ procedureName: 'listChargingStations' as never,
+ timeoutMs: Number.NaN,
+ }),
+ (error: Error) => {
+ assert.ok(error.message.includes('Invalid timeout'))
+ assert.ok(error.message.includes('NaN'))
+ return true
+ }
+ )
+ })
})