mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-18 05:20:48 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { SILENT_REPLY_TOKEN } from "../tokens.js";
|
|
import { normalizeReplyPayload } from "./normalize-reply.js";
|
|
|
|
// Keep channelData-only payloads so channel-specific replies survive normalization.
|
|
describe("normalizeReplyPayload", () => {
|
|
it("keeps channelData-only replies", () => {
|
|
const payload = {
|
|
channelData: {
|
|
line: {
|
|
flexMessage: { type: "bubble" },
|
|
},
|
|
},
|
|
};
|
|
|
|
const normalized = normalizeReplyPayload(payload);
|
|
|
|
expect(normalized).not.toBeNull();
|
|
expect(normalized?.text).toBeUndefined();
|
|
expect(normalized?.channelData).toEqual(payload.channelData);
|
|
});
|
|
|
|
it("records silent skips", () => {
|
|
const reasons: string[] = [];
|
|
const normalized = normalizeReplyPayload(
|
|
{ text: SILENT_REPLY_TOKEN },
|
|
{
|
|
onSkip: (reason) => reasons.push(reason),
|
|
},
|
|
);
|
|
|
|
expect(normalized).toBeNull();
|
|
expect(reasons).toEqual(["silent"]);
|
|
});
|
|
|
|
it("records empty skips", () => {
|
|
const reasons: string[] = [];
|
|
const normalized = normalizeReplyPayload(
|
|
{ text: " " },
|
|
{
|
|
onSkip: (reason) => reasons.push(reason),
|
|
},
|
|
);
|
|
|
|
expect(normalized).toBeNull();
|
|
expect(reasons).toEqual(["empty"]);
|
|
});
|
|
});
|