import assert from "node:assert/strict" import { formatServicePathLabel, formatServicePathTitle, isUnboundServicePath, } from "./format-service-path-label.ts" const bound = { clientId: "u1", clientName: "D", viaId: "7", viaName: "nsk-gw01", enId: "9", enName: "arn-gw01", serviceId: "svc:cdn", } const jhEn = { clientId: "—", clientName: "—", viaId: "7", viaName: "msk-gw01", enId: "9", enName: "arn-gw01", serviceId: "svc:cdn", } const enOnly = { clientId: "—", clientName: "—", viaId: "9", viaName: "arn-gw01", enId: "9", enName: "arn-gw01", serviceId: "svc:cdn", } assert.equal(isUnboundServicePath(jhEn), true) assert.equal(isUnboundServicePath(bound), false) assert.equal( formatServicePathLabel(jhEn, "via", { viaName: "msk-gw01.rtnt.top", enName: "arn-gw01.rtnt.top" }), "msk-gw01.rtnt.top → arn-gw01.rtnt.top", ) assert.equal(formatServicePathLabel(enOnly, "via"), "arn-gw01 · без привязки") assert.equal(formatServicePathLabel(enOnly, "service"), "arn-gw01 · без привязки") assert.equal( formatServicePathLabel(bound, "via", { viaSite: "NSK" }), "D · NSK", ) assert.equal( formatServicePathLabel(bound, "service", { serviceLabel: "CDN" }), "D · CDN", ) assert.equal( formatServicePathTitle("msk-gw01 → arn-gw01", "CDN"), "msk-gw01 → arn-gw01 · CDN", ) console.log("format-service-path-label.test.ts: ok")