diff --git a/extensions/twitch/src/actions.test.ts b/extensions/twitch/src/actions.test.ts index aa9c501c1d8..f214f20c042 100644 --- a/extensions/twitch/src/actions.test.ts +++ b/extensions/twitch/src/actions.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi, beforeEach } from "vitest"; import { twitchMessageActions } from "./actions.js"; +import type { ResolvedTwitchAccountContext } from "./config.js"; import { resolveTwitchAccountContext } from "./config.js"; import { twitchOutbound } from "./outbound.js"; @@ -14,6 +15,22 @@ vi.mock("./outbound.js", () => ({ }, })); +function createSecondaryAccountContext(accountId = "secondary"): ResolvedTwitchAccountContext { + return { + accountId, + account: { + channel: "secondary-channel", + username: "secondary", + accessToken: "oauth:secondary-token", + clientId: "secondary-client", + enabled: true, + }, + tokenResolution: { source: "config", token: "oauth:secondary-token" }, + configured: true, + availableAccountIds: ["default", "secondary"], + }; +} + describe("twitchMessageActions", () => { beforeEach(() => { vi.clearAllMocks(); @@ -21,32 +38,10 @@ describe("twitchMessageActions", () => { it("uses configured defaultAccount when action accountId is omitted", async () => { vi.mocked(resolveTwitchAccountContext) - .mockImplementationOnce(() => ({ - accountId: "secondary", - account: { - channel: "secondary-channel", - username: "secondary", - accessToken: "oauth:secondary-token", - clientId: "secondary-client", - enabled: true, - }, - tokenResolution: { source: "config", token: "oauth:secondary-token" }, - configured: true, - availableAccountIds: ["default", "secondary"], - })) - .mockImplementation((_cfg, accountId) => ({ - accountId: accountId?.trim() || "secondary", - account: { - channel: "secondary-channel", - username: "secondary", - accessToken: "oauth:secondary-token", - clientId: "secondary-client", - enabled: true, - }, - tokenResolution: { source: "config", token: "oauth:secondary-token" }, - configured: true, - availableAccountIds: ["default", "secondary"], - })); + .mockImplementationOnce(() => createSecondaryAccountContext()) + .mockImplementation((_cfg, accountId) => + createSecondaryAccountContext(accountId?.trim() || "secondary"), + ); const sendText = twitchOutbound.sendText; if (!sendText) { throw new Error("twitchOutbound.sendText is unavailable");