Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

831 B
Raw Blame
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,
    });
  });
});