test: guard acpx runtime mock calls

This commit is contained in:
Peter Steinberger
2026-05-12 01:16:53 +01:00
parent 24e5e373e2
commit e5a674a783
2 changed files with 10 additions and 2 deletions

View File

@@ -111,7 +111,11 @@ function makeLeaseStore() {
function readFirstEnsureSessionInput(ensure: {
mock: { calls: Array<Array<unknown>> };
}): Parameters<AcpRuntime["ensureSession"]>[0] {
const input = ensure.mock.calls[0]?.[0];
const [call] = ensure.mock.calls;
if (!call) {
throw new Error("Expected ensureSession to be called");
}
const [input] = call;
if (typeof input !== "object" || input === null) {
throw new Error("Expected ensureSession to be called with an input object");
}

View File

@@ -157,7 +157,11 @@ function createMockRuntime(overrides: Record<string, unknown> = {}) {
}
function readFirstRuntimeFactoryInput(runtimeFactory: { mock: { calls: Array<Array<unknown>> } }) {
const input = runtimeFactory.mock.calls[0]?.[0];
const [call] = runtimeFactory.mock.calls;
if (!call) {
throw new Error("Expected runtimeFactory to be called");
}
const [input] = call;
if (typeof input !== "object" || input === null) {
throw new Error("Expected runtimeFactory to be called with an options object");
}