58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { TenantSummary } from "../../../lib/adminApi";
|
|
import { filterParentTenants } from "./ParentTenantSelector.helpers";
|
|
|
|
const tenants: TenantSummary[] = [
|
|
{
|
|
id: "company-1",
|
|
type: "COMPANY",
|
|
name: "Saman Engineering",
|
|
slug: "saman",
|
|
description: "",
|
|
status: "active",
|
|
memberCount: 0,
|
|
createdAt: "",
|
|
updatedAt: "",
|
|
},
|
|
{
|
|
id: "group-1",
|
|
type: "COMPANY_GROUP",
|
|
name: "Hanmac Family",
|
|
slug: "hanmac-family",
|
|
description: "",
|
|
status: "active",
|
|
memberCount: 0,
|
|
createdAt: "",
|
|
updatedAt: "",
|
|
},
|
|
{
|
|
id: "org-1",
|
|
type: "ORGANIZATION",
|
|
name: "기획부",
|
|
slug: "planning",
|
|
description: "",
|
|
status: "active",
|
|
memberCount: 0,
|
|
createdAt: "",
|
|
updatedAt: "",
|
|
},
|
|
];
|
|
|
|
describe("filterParentTenants", () => {
|
|
it("searches parent candidates by name and slug", () => {
|
|
expect(
|
|
filterParentTenants(tenants, "saman", false).map((t) => t.id),
|
|
).toEqual(["company-1"]);
|
|
expect(
|
|
filterParentTenants(tenants, "family", false).map((t) => t.id),
|
|
).toEqual(["group-1"]);
|
|
});
|
|
|
|
it("can limit parent candidates to company and company group tenants", () => {
|
|
expect(filterParentTenants(tenants, "", true).map((t) => t.id)).toEqual([
|
|
"company-1",
|
|
"group-1",
|
|
]);
|
|
});
|
|
});
|