mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: guard discord qa helpers
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 = () =>
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user