test: fix discord/config test lint

This commit is contained in:
Peter Steinberger
2026-01-02 12:20:43 +01:00
parent b50df6eb1d
commit fd4cff06ca
2 changed files with 13 additions and 13 deletions

View File

@@ -206,7 +206,6 @@ describe("config identity defaults", () => {
});
});
import fs from "node:fs/promises";
describe("config discord", () => {
let previousHome: string | undefined;

View File

@@ -1,15 +1,16 @@
import { describe, expect, it } from "vitest";
import {
allowListMatches,
type DiscordGuildEntryResolved,
normalizeDiscordAllowList,
normalizeDiscordSlug,
resolveDiscordChannelConfig,
resolveDiscordGuildEntry,
resolveGroupDmAllow,
type DiscordGuildEntryResolved,
} from "./monitor.js";
const fakeGuild = (id: string, name: string) =>
({ id, name } as unknown as import("discord.js").Guild);
({ id, name }) as unknown as import("discord.js").Guild;
const makeEntries = (
entries: Record<string, Partial<DiscordGuildEntryResolved>>,
@@ -28,12 +29,9 @@ const makeEntries = (
describe("discord allowlist helpers", () => {
it("normalizes slugs", () => {
expect(normalizeDiscordSlug("Friends of Clawd"))
.toBe("friends-of-clawd");
expect(normalizeDiscordSlug("#General"))
.toBe("general");
expect(normalizeDiscordSlug("Dev__Chat"))
.toBe("dev-chat");
expect(normalizeDiscordSlug("Friends of Clawd")).toBe("friends-of-clawd");
expect(normalizeDiscordSlug("#General")).toBe("general");
expect(normalizeDiscordSlug("Dev__Chat")).toBe("dev-chat");
});
it("matches ids or names", () => {
@@ -42,10 +40,13 @@ describe("discord allowlist helpers", () => {
["discord:", "user:", "guild:", "channel:"],
);
expect(allow).not.toBeNull();
expect(allowListMatches(allow!, { id: "123" })).toBe(true);
expect(allowListMatches(allow!, { name: "steipete" })).toBe(true);
expect(allowListMatches(allow!, { name: "friends-of-clawd" })).toBe(true);
expect(allowListMatches(allow!, { name: "other" })).toBe(false);
if (!allow) {
throw new Error("Expected allow list to be normalized");
}
expect(allowListMatches(allow, { id: "123" })).toBe(true);
expect(allowListMatches(allow, { name: "steipete" })).toBe(true);
expect(allowListMatches(allow, { name: "friends-of-clawd" })).toBe(true);
expect(allowListMatches(allow, { name: "other" })).toBe(false);
});
});