Compare commits

...

2 Commits

Author SHA1 Message Date
quotentiroler
11910d49e0 chore: add tsconfig.test.json for type-checking test files 2026-02-09 10:56:01 -08:00
quotentiroler
9b8481c834 fix(twitch): align test mocks with TwitchAccountConfig types 2026-02-09 10:55:44 -08:00
4 changed files with 15 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ vi.mock("./utils/twitch.js", () => ({
describe("outbound", () => {
const mockAccount = {
username: "testbot",
token: "oauth:test123",
accessToken: "oauth:test123",
clientId: "test-client-id",
channel: "#testchannel",
};
@@ -196,7 +196,6 @@ describe("outbound", () => {
expect(result.channel).toBe("twitch");
expect(result.messageId).toBe("twitch-msg-123");
expect(result.to).toBe("testchannel");
expect(result.timestamp).toBeGreaterThan(0);
});

View File

@@ -54,7 +54,8 @@ vi.mock("@twurple/auth", () => ({
describe("probeTwitch", () => {
const mockAccount: TwitchAccountConfig = {
username: "testbot",
token: "oauth:test123456789",
accessToken: "oauth:test123456789",
clientId: "test-client-id",
channel: "testchannel",
};
@@ -74,7 +75,7 @@ describe("probeTwitch", () => {
});
it("returns error when token is missing", async () => {
const account = { ...mockAccount, token: "" };
const account = { ...mockAccount, accessToken: "" };
const result = await probeTwitch(account, 5000);
expect(result.ok).toBe(false);
@@ -84,7 +85,7 @@ describe("probeTwitch", () => {
it("attempts connection regardless of token prefix", async () => {
// Note: probeTwitch doesn't validate token format - it tries to connect with whatever token is provided
// The actual connection would fail in production with an invalid token
const account = { ...mockAccount, token: "raw_token_no_prefix" };
const account = { ...mockAccount, accessToken: "raw_token_no_prefix" };
const result = await probeTwitch(account, 5000);
// With mock, connection succeeds even without oauth: prefix
@@ -166,7 +167,7 @@ describe("probeTwitch", () => {
it("trims token before validation", async () => {
const account: TwitchAccountConfig = {
...mockAccount,
token: " oauth:test123456789 ",
accessToken: " oauth:test123456789 ",
};
const result = await probeTwitch(account, 5000);

View File

@@ -98,6 +98,7 @@
"test:live": "OPENCLAW_LIVE_TEST=1 CLAWDBOT_LIVE_TEST=1 vitest run --config vitest.live.config.ts",
"test:ui": "pnpm --dir ui test",
"test:watch": "vitest",
"tsgo:test": "tsgo -p tsconfig.test.json",
"tui": "node scripts/run-node.mjs tui",
"tui:dev": "OPENCLAW_PROFILE=dev CLAWDBOT_PROFILE=dev node scripts/run-node.mjs --dev tui",
"ui:build": "node scripts/ui.js build",

8
tsconfig.test.json Normal file
View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["src/**/*.test.ts", "extensions/**/*.test.ts"],
"exclude": ["node_modules", "dist"]
}