forked from baron/baron-sso
chore: consolidate local integration changes
This commit is contained in:
@@ -63,6 +63,50 @@ describe("tenantTree utility", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("uses backend total member counts without double-counting children", () => {
|
||||
const tenantsWithTotals: TenantSummary[] = [
|
||||
{
|
||||
...mockTenants[0],
|
||||
memberCount: 10,
|
||||
totalMemberCount: 17,
|
||||
},
|
||||
{
|
||||
...mockTenants[1],
|
||||
memberCount: 5,
|
||||
totalMemberCount: 7,
|
||||
},
|
||||
{
|
||||
...mockTenants[2],
|
||||
memberCount: 2,
|
||||
totalMemberCount: 2,
|
||||
},
|
||||
];
|
||||
|
||||
const { currentBase } = buildTenantFullTree(tenantsWithTotals, "root-1");
|
||||
|
||||
expect(currentBase?.recursiveMemberCount).toBe(17);
|
||||
expect(currentBase?.children[0]?.recursiveMemberCount).toBe(7);
|
||||
expect(currentBase?.children[0]?.children[0]?.recursiveMemberCount).toBe(
|
||||
2,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps total member counts when descendants are not loaded on the current page", () => {
|
||||
const { currentBase } = buildTenantFullTree(
|
||||
[
|
||||
{
|
||||
...mockTenants[0],
|
||||
memberCount: 10,
|
||||
totalMemberCount: 17,
|
||||
},
|
||||
],
|
||||
"root-1",
|
||||
);
|
||||
|
||||
expect(currentBase?.recursiveMemberCount).toBe(17);
|
||||
expect(currentBase?.children).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("returns null currentBase if rootId is not found", () => {
|
||||
const { currentBase } = buildTenantFullTree(mockTenants, "non-existent");
|
||||
expect(currentBase).toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user