1
2
10(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
11import { renderToStaticMarkup } from "react-dom/server";
12import { describe, expect, it } from "vitest";
13
14import { pageRowIcon } from "../page-tree-node";
15
16const render = (node: React.ReactNode) => renderToStaticMarkup(<>{node}</>);
17
18describe("pageRowIcon", () => {
19 it("renders a closed folder for a page with children", () => {
20 const html = render(pageRowIcon({ type: "page", icon: null }, true, false));
21 expect(html).toContain("lucide-folder");
22 expect(html).not.toContain("lucide-folder-open");
23 });
24
25 it("renders an open folder when the page with children is expanded", () => {
26 const html = render(pageRowIcon({ type: "page", icon: null }, true, true));
27 expect(html).toContain("lucide-folder-open");
28 });
29
30 it("renders a document icon for a page without children", () => {
31 const html = render(pageRowIcon({ type: "page", icon: null }, false, false));
32 expect(html).toContain("lucide-file-text");
33 expect(html).not.toContain("lucide-folder");
34 });
35
36 it("lets a user-set emoji win over the folder/document default", () => {
37 const html = render(pageRowIcon({ type: "page", icon: "📁" }, true, false));
38 expect(html).toContain("📁");
39 expect(html).not.toContain("lucide-folder");
40 });
41
42 it("keeps the database icon even when the page has children", () => {
43 const html = render(pageRowIcon({ type: "database", icon: null }, true, false));
44 expect(html).toContain("lucide-database");
45 expect(html).not.toContain("lucide-folder");
46 });
47
48 it("keeps the trash icon for trash entries", () => {
49 const html = render(pageRowIcon({ type: "trash", icon: null }, true, false));
50 expect(html).toContain("lucide-trash2");
51 expect(html).not.toContain("lucide-folder");
52 });
53});
54