test: fix discord/config test lint
This commit is contained in:
@@ -206,7 +206,6 @@ describe("config identity defaults", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
import fs from "node:fs/promises";
|
|
||||||
describe("config discord", () => {
|
describe("config discord", () => {
|
||||||
let previousHome: string | undefined;
|
let previousHome: string | undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
allowListMatches,
|
allowListMatches,
|
||||||
|
type DiscordGuildEntryResolved,
|
||||||
normalizeDiscordAllowList,
|
normalizeDiscordAllowList,
|
||||||
normalizeDiscordSlug,
|
normalizeDiscordSlug,
|
||||||
resolveDiscordChannelConfig,
|
resolveDiscordChannelConfig,
|
||||||
resolveDiscordGuildEntry,
|
resolveDiscordGuildEntry,
|
||||||
resolveGroupDmAllow,
|
resolveGroupDmAllow,
|
||||||
type DiscordGuildEntryResolved,
|
|
||||||
} from "./monitor.js";
|
} from "./monitor.js";
|
||||||
|
|
||||||
const fakeGuild = (id: string, name: string) =>
|
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 = (
|
const makeEntries = (
|
||||||
entries: Record<string, Partial<DiscordGuildEntryResolved>>,
|
entries: Record<string, Partial<DiscordGuildEntryResolved>>,
|
||||||
@@ -28,12 +29,9 @@ const makeEntries = (
|
|||||||
|
|
||||||
describe("discord allowlist helpers", () => {
|
describe("discord allowlist helpers", () => {
|
||||||
it("normalizes slugs", () => {
|
it("normalizes slugs", () => {
|
||||||
expect(normalizeDiscordSlug("Friends of Clawd"))
|
expect(normalizeDiscordSlug("Friends of Clawd")).toBe("friends-of-clawd");
|
||||||
.toBe("friends-of-clawd");
|
expect(normalizeDiscordSlug("#General")).toBe("general");
|
||||||
expect(normalizeDiscordSlug("#General"))
|
expect(normalizeDiscordSlug("Dev__Chat")).toBe("dev-chat");
|
||||||
.toBe("general");
|
|
||||||
expect(normalizeDiscordSlug("Dev__Chat"))
|
|
||||||
.toBe("dev-chat");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches ids or names", () => {
|
it("matches ids or names", () => {
|
||||||
@@ -42,10 +40,13 @@ describe("discord allowlist helpers", () => {
|
|||||||
["discord:", "user:", "guild:", "channel:"],
|
["discord:", "user:", "guild:", "channel:"],
|
||||||
);
|
);
|
||||||
expect(allow).not.toBeNull();
|
expect(allow).not.toBeNull();
|
||||||
expect(allowListMatches(allow!, { id: "123" })).toBe(true);
|
if (!allow) {
|
||||||
expect(allowListMatches(allow!, { name: "steipete" })).toBe(true);
|
throw new Error("Expected allow list to be normalized");
|
||||||
expect(allowListMatches(allow!, { name: "friends-of-clawd" })).toBe(true);
|
}
|
||||||
expect(allowListMatches(allow!, { name: "other" })).toBe(false);
|
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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user