Files
nianxx-h5/src/utils/socketUrl.test.ts
DEV_DSW b906058cdc feat: add service order component
- add CreateServiceOrder component and associated icon assets
- create reusable resolveChatSocketUrl utility with comprehensive test cases
- update development env config to use production websocket endpoint
- fix ChatCardAi layout by replacing inline-block with flex-1 class
- refactor ChatMainList websocket initialization to use the new socket utility
- switch to using environment variable for access token instead of getAccessToken
- correct relative import path for CreateServiceOrder in ChatMainList
2026-06-01 11:44:56 +08:00

42 lines
1.1 KiB
TypeScript

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