import { describe, expect, it } from "vitest"; import { isEmptyProjectSpace, isHauptthreadGroup, projectGroupChatsInSpace, } from "./project-empty-state.js"; describe("isHauptthreadGroup", () => { it("recognizes Hauptthread and Team Chat", () => { expect(isHauptthreadGroup({ id: "1", name: "Hauptthread" })).toBe(true); expect(isHauptthreadGroup({ id: "2", name: "Team Chat" })).toBe(true); expect(isHauptthreadGroup({ id: "3", name: "Launch" })).toBe(false); }); }); describe("projectGroupChatsInSpace", () => { it("returns project groups in a space without Hauptthread", () => { const groups = [ { id: "g1", name: "Launch", spaceId: "space-a" }, { id: "g2", name: "Hauptthread", spaceId: "space-a" }, { id: "g3", name: "Ops", spaceId: "space-b" }, ]; expect(projectGroupChatsInSpace(groups, "space-a").map((group) => group.id)).toEqual(["g1"]); }); }); describe("isEmptyProjectSpace", () => { const spaces = [ { id: "home", isDefault: true }, { id: "project", isDefault: false }, ]; it("is false for the home space", () => { expect(isEmptyProjectSpace("home", spaces, [], "home")).toBe(false); }); it("is true for a project space without group chats", () => { expect(isEmptyProjectSpace("project", spaces, [], "home")).toBe(true); }); it("is false when the project space already has a group chat", () => { const groups = [{ id: "g1", name: "Launch", spaceId: "project" }]; expect(isEmptyProjectSpace("project", spaces, groups, "home")).toBe(false); }); it("ignores Hauptthread when deciding emptiness", () => { const groups = [{ id: "g1", name: "Hauptthread", spaceId: "project" }]; expect(isEmptyProjectSpace("project", spaces, groups, "home")).toBe(true); }); });