openclaw/src/discord/monitor/provider.skill-dedupe.test.ts
seewhy ddcc7a1a5d
fix(discord): dedupe native skill commands by skillName (#17365)
* fix(discord): dedupe native skill commands by skill name

* Changelog: credit Discord skill dedupe

---------

Co-authored-by: yume <yume@yumedeMacBook-Pro.local>
Co-authored-by: Shadow <hi@shadowing.dev>
2026-02-15 20:33:51 -06:00

27 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { __testing } from "./provider.js";
describe("dedupeSkillCommandsForDiscord", () => {
it("keeps first command per skillName and drops suffix duplicates", () => {
const input = [
{ name: "github", skillName: "github", description: "GitHub" },
{ name: "github_2", skillName: "github", description: "GitHub" },
{ name: "weather", skillName: "weather", description: "Weather" },
{ name: "weather_2", skillName: "weather", description: "Weather" },
];
const output = __testing.dedupeSkillCommandsForDiscord(input);
expect(output.map((entry) => entry.name)).toEqual(["github", "weather"]);
});
it("treats skillName case-insensitively", () => {
const input = [
{ name: "ClawHub", skillName: "ClawHub", description: "ClawHub" },
{ name: "clawhub_2", skillName: "clawhub", description: "ClawHub" },
];
const output = __testing.dedupeSkillCommandsForDiscord(input);
expect(output).toHaveLength(1);
expect(output[0]?.name).toBe("ClawHub");
});
});