import { test } from "node:test"; import assert from "node:assert/strict"; import { pdsBaseUrls } from "../src/pdsUrls.js"; test("defaults to https/wss on the public hostname when no adminUrl is given", () => { assert.deepEqual(pdsBaseUrls("pds.example.com"), { http: "https://pds.example.com", ws: "wss://pds.example.com", }); }); test("an http adminUrl yields http/ws and preserves a custom port", () => { assert.deepEqual(pdsBaseUrls("pds.example.com", "http://pds.internal:3000"), { http: "http://pds.internal:3000", ws: "ws://pds.internal:3000", }); }); test("an https adminUrl yields https/wss", () => { assert.deepEqual(pdsBaseUrls("pds.example.com", "https://admin.pds.example.com"), { http: "https://admin.pds.example.com", ws: "wss://admin.pds.example.com", }); }); test("only the origin is used — any path in adminUrl is dropped", () => { assert.deepEqual(pdsBaseUrls("ignored", "http://pds.internal:3000/some/path"), { http: "http://pds.internal:3000", ws: "ws://pds.internal:3000", }); }); test("a malformed adminUrl throws (fail fast at construction)", () => { assert.throws(() => pdsBaseUrls("pds.example.com", "not a url")); });