From f934725ccdbedce29a18354e128641eba4cb758a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 23:38:52 +0000 Subject: [PATCH] perf(test): consolidate channel misc suites --- src/channel-web.barrel.test.ts | 14 -------- src/channels/channels-misc.test.ts | 56 ++++++++++++++++++++++++++++++ src/channels/chat-type.test.ts | 27 -------------- src/channels/web/index.test.ts | 18 ---------- 4 files changed, 56 insertions(+), 59 deletions(-) delete mode 100644 src/channel-web.barrel.test.ts create mode 100644 src/channels/channels-misc.test.ts delete mode 100644 src/channels/chat-type.test.ts delete mode 100644 src/channels/web/index.test.ts diff --git a/src/channel-web.barrel.test.ts b/src/channel-web.barrel.test.ts deleted file mode 100644 index 0c52598c3e..0000000000 --- a/src/channel-web.barrel.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { describe, expect, it } from "vitest"; -import * as mod from "./channel-web.js"; - -describe("channel-web barrel", () => { - it("exports the expected web helpers", () => { - expect(mod.createWaSocket).toBeTypeOf("function"); - expect(mod.loginWeb).toBeTypeOf("function"); - expect(mod.monitorWebChannel).toBeTypeOf("function"); - expect(mod.sendMessageWhatsApp).toBeTypeOf("function"); - expect(mod.monitorWebInbox).toBeTypeOf("function"); - expect(mod.pickWebChannel).toBeTypeOf("function"); - expect(mod.WA_WEB_AUTH_DIR).toBeTruthy(); - }); -}); diff --git a/src/channels/channels-misc.test.ts b/src/channels/channels-misc.test.ts new file mode 100644 index 0000000000..3eb51c509a --- /dev/null +++ b/src/channels/channels-misc.test.ts @@ -0,0 +1,56 @@ +import { describe, expect, it } from "vitest"; +import * as channelWeb from "../channel-web.js"; +import { normalizeChatType } from "./chat-type.js"; +import * as webEntry from "./web/index.js"; + +describe("channel-web barrel", () => { + it("exports the expected web helpers", () => { + expect(channelWeb.createWaSocket).toBeTypeOf("function"); + expect(channelWeb.loginWeb).toBeTypeOf("function"); + expect(channelWeb.monitorWebChannel).toBeTypeOf("function"); + expect(channelWeb.sendMessageWhatsApp).toBeTypeOf("function"); + expect(channelWeb.monitorWebInbox).toBeTypeOf("function"); + expect(channelWeb.pickWebChannel).toBeTypeOf("function"); + expect(channelWeb.WA_WEB_AUTH_DIR).toBeTruthy(); + }); +}); + +describe("normalizeChatType", () => { + it("normalizes common inputs", () => { + expect(normalizeChatType("direct")).toBe("direct"); + expect(normalizeChatType("dm")).toBe("direct"); + expect(normalizeChatType("group")).toBe("group"); + expect(normalizeChatType("channel")).toBe("channel"); + }); + + it("returns undefined for empty/unknown values", () => { + expect(normalizeChatType(undefined)).toBeUndefined(); + expect(normalizeChatType("")).toBeUndefined(); + expect(normalizeChatType("nope")).toBeUndefined(); + expect(normalizeChatType("room")).toBeUndefined(); + }); + + describe("backward compatibility", () => { + it("accepts legacy 'dm' value and normalizes to 'direct'", () => { + // Legacy config/input may use "dm" - ensure smooth upgrade path + expect(normalizeChatType("dm")).toBe("direct"); + expect(normalizeChatType("DM")).toBe("direct"); + expect(normalizeChatType(" dm ")).toBe("direct"); + }); + }); +}); + +describe("channels/web entrypoint", () => { + it("re-exports web channel helpers", () => { + expect(webEntry.createWaSocket).toBe(channelWeb.createWaSocket); + expect(webEntry.loginWeb).toBe(channelWeb.loginWeb); + expect(webEntry.logWebSelfId).toBe(channelWeb.logWebSelfId); + expect(webEntry.monitorWebInbox).toBe(channelWeb.monitorWebInbox); + expect(webEntry.monitorWebChannel).toBe(channelWeb.monitorWebChannel); + expect(webEntry.pickWebChannel).toBe(channelWeb.pickWebChannel); + expect(webEntry.sendMessageWhatsApp).toBe(channelWeb.sendMessageWhatsApp); + expect(webEntry.WA_WEB_AUTH_DIR).toBe(channelWeb.WA_WEB_AUTH_DIR); + expect(webEntry.waitForWaConnection).toBe(channelWeb.waitForWaConnection); + expect(webEntry.webAuthExists).toBe(channelWeb.webAuthExists); + }); +}); diff --git a/src/channels/chat-type.test.ts b/src/channels/chat-type.test.ts deleted file mode 100644 index 6775c8cac8..0000000000 --- a/src/channels/chat-type.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { normalizeChatType } from "./chat-type.js"; - -describe("normalizeChatType", () => { - it("normalizes common inputs", () => { - expect(normalizeChatType("direct")).toBe("direct"); - expect(normalizeChatType("dm")).toBe("direct"); - expect(normalizeChatType("group")).toBe("group"); - expect(normalizeChatType("channel")).toBe("channel"); - }); - - it("returns undefined for empty/unknown values", () => { - expect(normalizeChatType(undefined)).toBeUndefined(); - expect(normalizeChatType("")).toBeUndefined(); - expect(normalizeChatType("nope")).toBeUndefined(); - expect(normalizeChatType("room")).toBeUndefined(); - }); - - describe("backward compatibility", () => { - it("accepts legacy 'dm' value and normalizes to 'direct'", () => { - // Legacy config/input may use "dm" - ensure smooth upgrade path - expect(normalizeChatType("dm")).toBe("direct"); - expect(normalizeChatType("DM")).toBe("direct"); - expect(normalizeChatType(" dm ")).toBe("direct"); - }); - }); -}); diff --git a/src/channels/web/index.test.ts b/src/channels/web/index.test.ts deleted file mode 100644 index 8f62849579..0000000000 --- a/src/channels/web/index.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { describe, expect, it } from "vitest"; -import * as impl from "../../channel-web.js"; -import * as entry from "./index.js"; - -describe("channels/web entrypoint", () => { - it("re-exports web channel helpers", () => { - expect(entry.createWaSocket).toBe(impl.createWaSocket); - expect(entry.loginWeb).toBe(impl.loginWeb); - expect(entry.logWebSelfId).toBe(impl.logWebSelfId); - expect(entry.monitorWebInbox).toBe(impl.monitorWebInbox); - expect(entry.monitorWebChannel).toBe(impl.monitorWebChannel); - expect(entry.pickWebChannel).toBe(impl.pickWebChannel); - expect(entry.sendMessageWhatsApp).toBe(impl.sendMessageWhatsApp); - expect(entry.WA_WEB_AUTH_DIR).toBe(impl.WA_WEB_AUTH_DIR); - expect(entry.waitForWaConnection).toBe(impl.waitForWaConnection); - expect(entry.webAuthExists).toBe(impl.webAuthExists); - }); -});