perf(test): consolidate channel misc suites

This commit is contained in:
Peter Steinberger
2026-02-15 23:38:52 +00:00
parent 5709b30700
commit f934725ccd
4 changed files with 56 additions and 59 deletions

View File

@@ -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();
});
});

View File

@@ -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);
});
});

View File

@@ -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");
});
});
});

View File

@@ -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);
});
});