* wip * copy polugin files * wip type changes * refactor: improve Twitch plugin code quality and fix all tests - Extract client manager registry for centralized lifecycle management - Refactor to use early returns and reduce mutations - Fix status check logic for clientId detection - Add comprehensive test coverage for new modules - Remove tests for unimplemented features (index.test.ts, resolver.test.ts) - Fix mock setup issues in test suite (149 tests now passing) - Improve error handling with errorResponse helper in actions.ts - Normalize token handling to eliminate duplication Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * use accountId * delete md file * delte tsconfig * adjust log level * fix probe logic * format * fix monitor * code review fixes * format * no mutation * less mutation * chain debug log * await authProvider setup * use uuid * use spread * fix tests * update docs and remove bot channel fallback * more readme fixes * remove comments + fromat * fix tests * adjust access control logic * format * install * simplify config object * remove duplicate log tags + log received messages * update docs * update tests * format * strip markdown in monitor * remove strip markdown config, enabled by default * default requireMention to true * fix store path arg * fix multi account id + add unit test * fix multi account id + add unit test * make channel required and update docs * remove whisper functionality * remove duplicate connect log * update docs with convert twitch link * make twitch message processing non blocking * schema consistent casing * remove noisy ignore log * use coreLogger --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
89 lines
2.3 KiB
TypeScript
89 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { getAccountConfig } from "./config.js";
|
|
|
|
describe("getAccountConfig", () => {
|
|
const mockMultiAccountConfig = {
|
|
channels: {
|
|
twitch: {
|
|
accounts: {
|
|
default: {
|
|
username: "testbot",
|
|
accessToken: "oauth:test123",
|
|
},
|
|
secondary: {
|
|
username: "secondbot",
|
|
accessToken: "oauth:secondary",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const mockSimplifiedConfig = {
|
|
channels: {
|
|
twitch: {
|
|
username: "testbot",
|
|
accessToken: "oauth:test123",
|
|
},
|
|
},
|
|
};
|
|
|
|
it("returns account config for valid account ID (multi-account)", () => {
|
|
const result = getAccountConfig(mockMultiAccountConfig, "default");
|
|
|
|
expect(result).not.toBeNull();
|
|
expect(result?.username).toBe("testbot");
|
|
});
|
|
|
|
it("returns account config for default account (simplified config)", () => {
|
|
const result = getAccountConfig(mockSimplifiedConfig, "default");
|
|
|
|
expect(result).not.toBeNull();
|
|
expect(result?.username).toBe("testbot");
|
|
});
|
|
|
|
it("returns non-default account from multi-account config", () => {
|
|
const result = getAccountConfig(mockMultiAccountConfig, "secondary");
|
|
|
|
expect(result).not.toBeNull();
|
|
expect(result?.username).toBe("secondbot");
|
|
});
|
|
|
|
it("returns null for non-existent account ID", () => {
|
|
const result = getAccountConfig(mockMultiAccountConfig, "nonexistent");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("returns null when core config is null", () => {
|
|
const result = getAccountConfig(null, "default");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("returns null when core config is undefined", () => {
|
|
const result = getAccountConfig(undefined, "default");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("returns null when channels are not defined", () => {
|
|
const result = getAccountConfig({}, "default");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("returns null when twitch is not defined", () => {
|
|
const result = getAccountConfig({ channels: {} }, "default");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("returns null when accounts are not defined", () => {
|
|
const result = getAccountConfig({ channels: { twitch: {} } }, "default");
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|