mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 23:14:47 +00:00
test: guard browser gateway mock calls
This commit is contained in:
@@ -76,7 +76,7 @@ function invokeParams(nodeRegistry: ReturnType<typeof createContext>) {
|
||||
}
|
||||
|
||||
function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall {
|
||||
const call = respond.mock.calls[0] as RespondCall | undefined;
|
||||
const [call] = respond.mock.calls as RespondCall[];
|
||||
if (!call) {
|
||||
throw new Error("expected respond call");
|
||||
}
|
||||
|
||||
@@ -100,9 +100,12 @@ async function browserRequestStatus(): Promise<unknown> {
|
||||
req: { type: "req", id: "req-1", method: "browser.request" },
|
||||
isWebchatConnect: () => false,
|
||||
});
|
||||
const call = respond.mock.calls[0];
|
||||
expect(call?.[0]).toBe(true);
|
||||
return call?.[1];
|
||||
const [call] = respond.mock.calls;
|
||||
if (!call) {
|
||||
throw new Error("expected browser request response");
|
||||
}
|
||||
expect(call[0]).toBe(true);
|
||||
return call[1];
|
||||
}
|
||||
|
||||
describe("browser.request local control state", () => {
|
||||
|
||||
@@ -62,7 +62,11 @@ describe("browser.request local timeout", () => {
|
||||
});
|
||||
|
||||
expect(withTimeoutMock).toHaveBeenCalledTimes(1);
|
||||
const [dispatchTask, timeoutMs, timeoutLabel] = withTimeoutMock.mock.calls[0];
|
||||
const [call] = withTimeoutMock.mock.calls;
|
||||
if (!call) {
|
||||
throw new Error("expected withTimeout call");
|
||||
}
|
||||
const [dispatchTask, timeoutMs, timeoutLabel] = call;
|
||||
expect(dispatchTask).toBeTypeOf("function");
|
||||
expect(timeoutMs).toBe(4321);
|
||||
expect(timeoutLabel).toBe("browser request");
|
||||
|
||||
Reference in New Issue
Block a user