mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:24:31 +00:00
test: normalize outbound payload fixture typing
This commit is contained in:
committed by
Peter Steinberger
parent
828f4e18e0
commit
60c735dd98
@@ -4,6 +4,7 @@ import path from "node:path";
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { telegramPlugin } from "../../../extensions/telegram/src/channel.js";
|
import { telegramPlugin } from "../../../extensions/telegram/src/channel.js";
|
||||||
import { whatsappPlugin } from "../../../extensions/whatsapp/src/channel.js";
|
import { whatsappPlugin } from "../../../extensions/whatsapp/src/channel.js";
|
||||||
|
import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||||
import { createTestRegistry } from "../../test-utils/channel-plugins.js";
|
import { createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||||
@@ -847,12 +848,14 @@ describe("normalizeOutboundPayloadsForJson", () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const testCase of cases) {
|
for (const testCase of cases) {
|
||||||
const input = testCase.input.map((payload) => {
|
const input: ReplyPayload[] = testCase.input.map((payload) =>
|
||||||
if ("mediaUrls" in payload && payload.mediaUrls) {
|
"mediaUrls" in payload
|
||||||
return { ...payload, mediaUrls: [...payload.mediaUrls] };
|
? ({
|
||||||
}
|
...payload,
|
||||||
return { ...payload };
|
mediaUrls: payload.mediaUrls ? [...payload.mediaUrls] : undefined,
|
||||||
});
|
} as ReplyPayload)
|
||||||
|
: ({ ...payload } as ReplyPayload),
|
||||||
|
);
|
||||||
expect(normalizeOutboundPayloadsForJson(input)).toEqual(testCase.expected);
|
expect(normalizeOutboundPayloadsForJson(input)).toEqual(testCase.expected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user