testOwnNamesKeepTheReadme

tcmts.registry.test.testOwnNamesKeepTheReadme · #47gycrpn · term

A mirrored release's own names include the files kept with its code (its README, which its page shows), but not the libraries it holds, nor their record.

import { save } from "#codebase/tcmts/cli/main";
import { ownNames } from "#codebase/tcmts/registry";
import { codebaseHolding } from "#codebase/tcmts/registry/test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

export const testOwnNamesKeepTheReadme = () => {
  const mount = "plc_alice.geo.v1_0_0";
  const { cb, dir } = codebaseHolding(
    "own names",
    `// tcm: namespace ${mount}\nexport const area = (side: number) => side * side;\n`,
    mount,
  );
  const add = (file: string, text: string) => {
    fs.writeFileSync(path.join(dir, file), text);
    save(cb, path.join(dir, file), "add");
  };
  add("README.md", `<!-- tcm: path ${mount}.README -->\n# geo\n\nShapes.\n`);
  add(
    "held.ts",
    `// tcm: namespace ${mount}.lib.shapes\nexport const sq = (n: number) => n * n;\n`,
  );
  assert.deepEqual(
    ownNames(cb, mount).map((n) => [n.path.slice(mount.length + 1), n.kind]),
    [
      ["README", "file"],
      ["area", "term"],
    ],
  );
}

uses