memos/web/tests/tag-tree.test.ts
johnnyjoygh 6fbc81337f chore(sidebar): improve view and tag controls
- expose display settings from the Views header and refine layout controls
- add explicit tag list/tree navigation with accessible expansion behavior
- cover view persistence, menu behavior, and tag tree construction
2026-08-05 23:12:49 +08:00

32 lines
831 B
TypeScript

import { describe, expect, it } from "vitest";
import { buildTagTree } from "@/components/TagTree";
describe("tag tree", () => {
it("preserves exact counts, including one", () => {
const tree = buildTagTree([
["a", 2],
["a/b", 1],
]);
expect(tree).toMatchObject([
{
key: "a",
text: "a",
amount: 2,
subTags: [{ key: "b", text: "a/b", amount: 1, subTags: [] }],
},
]);
});
it("keeps generated parent paths structural", () => {
const tree = buildTagTree([["personal/travel/singapore", 2]]);
expect(tree[0].amount).toBeUndefined();
expect(tree[0].subTags[0].amount).toBeUndefined();
expect(tree[0].subTags[0].subTags[0]).toMatchObject({
key: "singapore",
text: "personal/travel/singapore",
amount: 2,
});
});
});