testEntrySummariesMatchDiffNamespaces
What the history says each entry changed is what diffNamespaces says, of the entry's names and its parent's read whole, whichever order the entries are asked for in (each entry's names are made from the last ones read).
import { stateAt } from "#codebase/tcmts/cli/changes"; import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { diffNamespaces } from "#codebase/tcmts/cli/diff"; import { entrySummary, shareCache, summaryOf } from "#codebase/tcmts/share"; import { storyStore } from "#codebase/tcmts/share/test"; import assert from "node:assert/strict"; export const testEntrySummariesMatchDiffNamespaces = () => { const { store, entries } = storyStore(); const cb = { store } as unknown as Codebase; const whole = (hash: string) => { const c = store.causal(hash)!; return summaryOf( diffNamespaces(stateAt(cb, c.parents[0]!), stateAt(cb, hash), (h) => store.getDef(h)!.ir), ); }; const expected = entries.map(whole); for (const order of [ [6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6], [3, 0, 6, 1, 5, 2, 4], ]) { const s = { cb, cache: shareCache() }; for (const i of order) assert.deepEqual( entrySummary(s, entries[i]!), expected[i], `entry ${i}, in the order ${order}`, ); } // (the story has each kind of change in it) assert.deepEqual(expected[1], { edited: ["lib.a", "lib.c"], added: [], removed: [], renamed: [], propagated: 1, }); assert.deepEqual(expected[2]!.renamed, [{ from: "lib.s", to: "lib.sub.s" }]); assert.deepEqual(expected[3]!.added, [], "an alias isn't an addition"); assert.deepEqual(expected[4]!.edited, ["lib.T"]); assert.deepEqual([expected[6]!.removed, expected[6]!.added], [["lib.c"], ["lib.e"]]); }