mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 10:10:43 +00:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
normalizeManifestCommandAliases,
|
|
resolveManifestCommandAliasOwnerInRegistry,
|
|
} from "./manifest-command-aliases.js";
|
|
|
|
describe("manifest command aliases", () => {
|
|
it("normalizes string and object entries", () => {
|
|
expect(
|
|
normalizeManifestCommandAliases([
|
|
"memory",
|
|
{ name: "reindex", kind: "runtime-slash", cliCommand: "memory" },
|
|
{ name: "" },
|
|
{ name: "bad-kind", kind: "unknown" },
|
|
]),
|
|
).toEqual([
|
|
{ name: "memory" },
|
|
{ name: "reindex", kind: "runtime-slash", cliCommand: "memory" },
|
|
{ name: "bad-kind" },
|
|
]);
|
|
});
|
|
|
|
it("resolves aliases without treating plugin ids as command aliases", () => {
|
|
const registry = {
|
|
plugins: [
|
|
{
|
|
id: "memory-core",
|
|
commandAliases: [{ name: "memory", kind: "runtime-slash" as const }],
|
|
},
|
|
{
|
|
id: "memory",
|
|
commandAliases: [{ name: "legacy-memory" }],
|
|
},
|
|
],
|
|
};
|
|
|
|
expect(resolveManifestCommandAliasOwnerInRegistry({ command: "memory", registry })).toBe(
|
|
undefined,
|
|
);
|
|
expect(
|
|
resolveManifestCommandAliasOwnerInRegistry({ command: "legacy-memory", registry }),
|
|
).toMatchObject({
|
|
pluginId: "memory",
|
|
name: "legacy-memory",
|
|
});
|
|
});
|
|
});
|