update tests

This commit is contained in:
jaydenfyi 2026-01-25 20:05:56 +08:00
parent cc9af164a8
commit 900d7b74c9

View File

@ -69,16 +69,15 @@ describe("probeTwitch", () => {
});
it("returns error when username is missing", async () => {
const account = { ...mockAccount, username: "" as unknown as string };
const account = { ...mockAccount, username: "" };
const result = await probeTwitch(account, 5000);
expect(result.ok).toBe(false);
expect(result.error).toContain("missing credentials");
expect(result.elapsedMs).toBeGreaterThanOrEqual(0);
});
it("returns error when token is missing", async () => {
const account = { ...mockAccount, token: "" as unknown as string };
const account = { ...mockAccount, token: "" };
const result = await probeTwitch(account, 5000);
expect(result.ok).toBe(false);
@ -102,7 +101,6 @@ describe("probeTwitch", () => {
expect(result.connected).toBe(true);
expect(result.username).toBe("testbot");
expect(result.channel).toBe("testchannel"); // uses account's configured channel
expect(result.elapsedMs).toBeGreaterThan(0);
});
it("uses custom channel when specified", async () => {
@ -149,13 +147,6 @@ describe("probeTwitch", () => {
mockConnect.mockImplementation(defaultConnectImpl);
});
it("measures elapsed time", async () => {
const result = await probeTwitch(mockAccount, 5000);
expect(result.ok).toBe(true);
expect(result.elapsedMs).toBeGreaterThan(0);
});
it("handles connection errors gracefully", async () => {
mockConnect.mockImplementationOnce(async () => {
// Simulate connection failure by calling disconnect handler