import { describe, expect, it } from "vitest"; import canonicalUrlUtils, { adminPath, adminUrl, apiPath, apiUrl, appPath, appUrl, } from "./canonical.js"; import type { AppPathOptions, CanonicalUrlMode } from "./canonical.js"; describe("@hivegrid/url canonical exports", () => { it("exports canonical helpers and the default helper object", () => { expect(appPath({ tenantSlug: "acme" })).toBe("/acme"); expect(adminPath("users")).toBe("/users"); expect(apiPath("health")).toBe("/v1/health"); expect(appUrl({ rootDomain: "example.com", tenantSlug: "acme" })).toBe("https://example.com/acme"); expect(adminUrl({ rootDomain: "example.com", path: "users" })).toBe("https://example.com/users"); expect(apiUrl({ rootDomain: "example.com", path: "health" })).toBe("https://example.com/v1/health"); expect(canonicalUrlUtils).toMatchObject({ appPath, adminPath, apiPath, appUrl, adminUrl, apiUrl }); }); it("keeps public types importable", () => { const mode: CanonicalUrlMode = "host-aware"; const options: AppPathOptions = { tenantSlug: "acme", mode }; expect(appPath(options)).toBe("/acme"); }); });