testReachesInALine

tcmts.registry.test.testReachesInALine · #g6mqq7u4 · term

What a release reaches, in a line: nothing, one definition, a few, many; through a package, said once.

import { reachesShort } from "#codebase/tcmts/registry";
import assert from "node:assert/strict";

export const testReachesInALine = () => {
  const said = (effects: Record<string, string[]>, unknown: string[] = []) =>
    reachesShort({ reaches: "long", effects, unknown });
  assert.equal(said({}), "reaches nothing outside itself");
  assert.equal(said({ network: ["fetchTiles"] }), "only `fetchTiles` reaches the network");
  assert.equal(
    said({ files: ["save"], network: ["fetchTiles", "save"] }),
    "`fetchTiles` and `save` reach the network and files",
  );
  assert.equal(
    said({
      clock: ["Pages (react)", "Stylesheet (react)", "createRouter (react)"],
      random: ["Pages (react)", "Stylesheet (react)", "createRouter (react)"],
      environment: ["Pages (react)", "Stylesheet (react)", "createRouter (react)"],
      output: ["Pages (react)", "Stylesheet (react)", "createRouter (react)"],
    }),
    "`Pages`, `Stylesheet` and `createRouter` reach the environment, the clock and 2 more, through react",
  );
  assert.equal(
    said({ network: ["a", "b", "c", "d"] }, ["@atcute/crypto"]),
    "4 definitions reach the network; can't tell for @atcute/crypto",
  );
  // (facts from before effects were kept: as they said it)
  assert.equal(reachesShort({ reaches: "reaches the clock (x)" }), "reaches the clock (x)");
}

uses