






















@@ -1,27 +1,61 @@
11import { beforeEach, describe, expect, it, vi } from "vitest";
223+type MockChannelSetupEntry = {
4+id: string;
5+pluginId?: string;
6+meta: {
7+id: string;
8+label: string;
9+selectionLabel?: string;
10+docsPath?: string;
11+docsLabel?: string;
12+blurb?: string;
13+selectionDocsPrefix?: string;
14+selectionExtras?: readonly string[];
15+exposure?: { setup?: boolean };
16+showInSetup?: boolean;
17+quickstartAllowFrom?: boolean;
18+};
19+};
20+21+type MockChannelSetupEntries = {
22+entries: MockChannelSetupEntry[];
23+installedCatalogEntries: MockChannelSetupEntry[];
24+installableCatalogEntries: MockChannelSetupEntry[];
25+installedCatalogById: Map<unknown, unknown>;
26+installableCatalogById: Map<unknown, unknown>;
27+};
28+329const listChatChannels = vi.hoisted(() =>
430vi.fn(() => [
531{ id: "discord", label: "Discord" },
632{ id: "bluebubbles", label: "BlueBubbles" },
733]),
834);
935const resolveChannelSetupEntries = vi.hoisted(() =>
10-vi.fn(() => ({
11-entries: [],
12-installedCatalogEntries: [],
13-installableCatalogEntries: [],
14-installedCatalogById: new Map(),
15-installableCatalogById: new Map(),
16-})),
36+vi.fn(
37+(_params?: unknown): MockChannelSetupEntries => ({
38+entries: [],
39+installedCatalogEntries: [],
40+installableCatalogEntries: [],
41+installedCatalogById: new Map(),
42+installableCatalogById: new Map(),
43+}),
44+),
1745);
1846const formatChannelPrimerLine = vi.hoisted(() =>
19-vi.fn((meta: { label: string; blurb: string }) => `${meta.label}: ${meta.blurb}`),
47+vi.fn((meta: unknown) => {
48+const channel = meta as { label: string; blurb: string };
49+return `${channel.label}: ${channel.blurb}`;
50+}),
2051);
2152const formatChannelSelectionLine = vi.hoisted(() =>
22-vi.fn((meta: { label: string; blurb: string }) => `${meta.label} — ${meta.blurb}`),
53+vi.fn((meta: unknown, _docsLink?: unknown) => {
54+const channel = meta as { label: string; blurb: string };
55+return `${channel.label} — ${channel.blurb}`;
56+}),
2357);
24-const isChannelConfigured = vi.hoisted(() => vi.fn(() => false));
58+const isChannelConfigured = vi.hoisted(() => vi.fn((_cfg?: unknown, _channelId?: string) => false));
25592660vi.mock("../channels/chat-meta.js", () => ({
2761listChatChannels: () => listChatChannels(),
@@ -64,12 +98,14 @@ describe("resolveChannelSetupSelectionContributions", () => {
6498installedCatalogById: new Map(),
6599installableCatalogById: new Map(),
66100});
67-formatChannelPrimerLine.mockImplementation(
68-(meta: { label: string; blurb: string }) => `${meta.label}: ${meta.blurb}`,
69-);
70-formatChannelSelectionLine.mockImplementation(
71-(meta: { label: string; blurb: string }) => `${meta.label} — ${meta.blurb}`,
72-);
101+formatChannelPrimerLine.mockImplementation((meta: unknown) => {
102+const channel = meta as { label: string; blurb: string };
103+return `${channel.label}: ${channel.blurb}`;
104+});
105+formatChannelSelectionLine.mockImplementation((meta: unknown) => {
106+const channel = meta as { label: string; blurb: string };
107+return `${channel.label} — ${channel.blurb}`;
108+});
73109isChannelConfigured.mockReturnValue(false);
74110});
75111此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。