import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { resolveChatSocketUrl } from "./socketUrl.ts"; const locationLike = { protocol: "http:", host: "localhost:5174", }; describe("resolveChatSocketUrl", () => { it("keeps a complete ws chat endpoint", () => { assert.equal( resolveChatSocketUrl( "wss://onefeel.brother7.cn/ingress/agent/ws/chat", locationLike, ), "wss://onefeel.brother7.cn/ingress/agent/ws/chat", ); }); it("adds the chat path to a configured websocket origin", () => { assert.equal( resolveChatSocketUrl("wss://onefeel.brother7.cn", locationLike), "wss://onefeel.brother7.cn/ingress/agent/ws/chat", ); }); it("adds the chat path to an ingress base path", () => { assert.equal( resolveChatSocketUrl("/ingress", locationLike), "ws://localhost:5174/ingress/agent/ws/chat", ); }); it("uses the current host when config is empty", () => { assert.equal( resolveChatSocketUrl("", locationLike), "ws://localhost:5174/ingress/agent/ws/chat", ); }); });