import { describe, expect, it } from "vitest"; import { getTenantSwitchPath } from "./tenant-switch-url"; const currentTenant = { id: "tenant_123", slug: "acme", }; describe("getTenantSwitchPath", () => { it("keeps the current child path when switching tenants", () => { expect( getTenantSwitchPath({ currentTenant, location: { pathname: "/acme/settings/members" }, tenantSlug: "beta", }), ).toBe("/beta/settings/members"); }); it("supports legacy app-prefixed tenant paths without preserving the legacy prefix", () => { expect( getTenantSwitchPath({ currentTenant, location: { pathname: "/app/acme/entities/rows" }, tenantSlug: "beta", }), ).toBe("/beta/entities/rows"); }); it("does not carry scope-bearing query or hash state into the next tenant", () => { expect( getTenantSwitchPath({ currentTenant, location: { pathname: "/acme/entities/rows", search: "?tenantId=tenant_123", hash: "#row_1" }, tenantSlug: "beta", }), ).toBe("/beta/entities/rows"); }); });