mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 08:51:10 +00:00
feat(discord): support forum tag edits via channel-edit (#12070) (thanks @xiaoyaner0201)
This commit is contained in:
28
src/agents/tools/common.test.ts
Normal file
28
src/agents/tools/common.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { parseAvailableTags } from "./common.js";
|
||||
|
||||
describe("parseAvailableTags", () => {
|
||||
test("returns undefined for non-array inputs", () => {
|
||||
expect(parseAvailableTags(undefined)).toBeUndefined();
|
||||
expect(parseAvailableTags(null)).toBeUndefined();
|
||||
expect(parseAvailableTags("oops")).toBeUndefined();
|
||||
});
|
||||
|
||||
test("drops entries without a string name and returns undefined when empty", () => {
|
||||
expect(parseAvailableTags([{ id: "1" }])).toBeUndefined();
|
||||
expect(parseAvailableTags([{ name: 123 }])).toBeUndefined();
|
||||
});
|
||||
|
||||
test("keeps falsy ids and sanitizes emoji fields", () => {
|
||||
const result = parseAvailableTags([
|
||||
{ id: "0", name: "General", emoji_id: null },
|
||||
{ id: "1", name: "Docs", emoji_name: "📚" },
|
||||
{ name: "Bad", emoji_id: 123 },
|
||||
]);
|
||||
expect(result).toEqual([
|
||||
{ id: "0", name: "General", emoji_id: null },
|
||||
{ id: "1", name: "Docs", emoji_name: "📚" },
|
||||
{ name: "Bad" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user