mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import { createRequire } from "node:module";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
hasBundledChannelConfiguredState,
|
|
listBundledChannelIdsWithConfiguredState,
|
|
} from "./configured-state.js";
|
|
|
|
const nodeRequire = createRequire(import.meta.url);
|
|
|
|
describe("bundled channel configured-state metadata", () => {
|
|
it("lists the shipped metadata-first configured-state channels", () => {
|
|
expect(listBundledChannelIdsWithConfiguredState()).toEqual(
|
|
expect.arrayContaining(["discord", "irc", "slack", "telegram"]),
|
|
);
|
|
});
|
|
|
|
it("resolves Discord, Slack, Telegram, and IRC env probes without full plugin loads", () => {
|
|
expect(
|
|
hasBundledChannelConfiguredState({
|
|
channelId: "discord",
|
|
cfg: {},
|
|
env: { DISCORD_BOT_TOKEN: "token" },
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
hasBundledChannelConfiguredState({
|
|
channelId: "slack",
|
|
cfg: {},
|
|
env: { SLACK_BOT_TOKEN: "xoxb-test" },
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
hasBundledChannelConfiguredState({
|
|
channelId: "telegram",
|
|
cfg: {},
|
|
env: { TELEGRAM_BOT_TOKEN: "token" },
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
hasBundledChannelConfiguredState({
|
|
channelId: "irc",
|
|
cfg: {},
|
|
env: { IRC_HOST: "irc.example.com", IRC_NICK: "openclaw" },
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("uses declarative env metadata without a TypeScript source require hook", () => {
|
|
const previousTsHook = nodeRequire.extensions[".ts"];
|
|
delete nodeRequire.extensions[".ts"];
|
|
try {
|
|
expect(
|
|
hasBundledChannelConfiguredState({
|
|
channelId: "discord",
|
|
cfg: {},
|
|
env: { DISCORD_BOT_TOKEN: "token" },
|
|
}),
|
|
).toBe(true);
|
|
} finally {
|
|
if (previousTsHook) {
|
|
nodeRequire.extensions[".ts"] = previousTsHook;
|
|
}
|
|
}
|
|
});
|
|
});
|