test: guard discord qa helpers

This commit is contained in:
Peter Steinberger
2026-05-11 19:34:48 +01:00
parent 578fad471a
commit c741d92d06
3 changed files with 12 additions and 6 deletions

View File

@@ -57,8 +57,10 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
function callArg(mock: unknown, callIndex: number, argIndex: number, label: string) {
const calls = (mock as { mock?: { calls?: Array<Array<unknown>> } }).mock?.calls ?? [];
const call = calls.at(callIndex);
expect(call, label).toBeDefined();
return call?.[argIndex];
if (!call) {
throw new Error(`Expected ${label}`);
}
return call[argIndex];
}
function expectRestBodyField(mock: unknown, field: string, expected: unknown) {

View File

@@ -386,8 +386,10 @@ describe("DiscordVoiceManager", () => {
const expectOffEventWithFunction = (source: MockCallSource, event: string) => {
const call = Array.from(source.mock.calls).find((candidate) => candidate[0] === event);
expect(call, `${event} listener removal`).toBeDefined();
expect(call?.[1], `${event} listener`).toBeTypeOf("function");
if (!call) {
throw new Error(`Expected ${event} listener removal`);
}
expect(call[1], `${event} listener`).toBeTypeOf("function");
};
const lastAgentCommandArgs = () =>

View File

@@ -28,8 +28,10 @@ vi.mock("openclaw/plugin-sdk/ssrf-runtime", async () => {
function requireScenario<T extends { id: string }>(scenarios: T[], id: string): T {
const scenario = scenarios.find((candidate) => candidate.id === id);
expect(scenario).toBeDefined();
return scenario as T;
if (!scenario) {
throw new Error(`Expected scenario ${id}`);
}
return scenario;
}
describe("telegram live qa runtime", () => {