mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 14:04:58 +00:00
refactor: consolidate typing lifecycle and queue policy
This commit is contained in:
42
src/channels/registry.helpers.test.ts
Normal file
42
src/channels/registry.helpers.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
formatChannelSelectionLine,
|
||||
listChatChannels,
|
||||
normalizeChatChannelId,
|
||||
} from "./registry.js";
|
||||
|
||||
describe("channel registry helpers", () => {
|
||||
it("normalizes aliases + trims whitespace", () => {
|
||||
expect(normalizeChatChannelId(" imsg ")).toBe("imessage");
|
||||
expect(normalizeChatChannelId("gchat")).toBe("googlechat");
|
||||
expect(normalizeChatChannelId("google-chat")).toBe("googlechat");
|
||||
expect(normalizeChatChannelId("internet-relay-chat")).toBe("irc");
|
||||
expect(normalizeChatChannelId("telegram")).toBe("telegram");
|
||||
expect(normalizeChatChannelId("web")).toBeNull();
|
||||
expect(normalizeChatChannelId("nope")).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps Telegram first in the default order", () => {
|
||||
const channels = listChatChannels();
|
||||
expect(channels[0]?.id).toBe("telegram");
|
||||
});
|
||||
|
||||
it("does not include MS Teams by default", () => {
|
||||
const channels = listChatChannels();
|
||||
expect(channels.some((channel) => channel.id === "msteams")).toBe(false);
|
||||
});
|
||||
|
||||
it("formats selection lines with docs labels + website extras", () => {
|
||||
const channels = listChatChannels();
|
||||
const first = channels[0];
|
||||
if (!first) {
|
||||
throw new Error("Missing channel metadata.");
|
||||
}
|
||||
const line = formatChannelSelectionLine(first, (path, label) =>
|
||||
[label, path].filter(Boolean).join(":"),
|
||||
);
|
||||
expect(line).not.toContain("Docs:");
|
||||
expect(line).toContain("/channels/telegram");
|
||||
expect(line).toContain("https://openclaw.ai");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user