MCPcopy Index your code
hub / github.com/modem-dev/hunk / createTestDiffFile

Function createTestDiffFile

test/helpers/diff-helpers.ts:48–87  ·  view source on GitHub ↗
({
  after = "const alpha = 10;\nconst beta = 2;\nconst gamma = 30;\nconst stable = true;\n",
  before = "const alpha = 1;\nconst beta = 2;\nconst gamma = 3;\nconst stable = true;\n",
  id = "example",
  language = "typescript",
  path = "example.ts",
  previousPath,
  context = 0,
  agent = null,
  sourceFetcher,
}: {
  after?: string;
  before?: string;
  id?: string;
  language?: string;
  path?: string;
  previousPath?: string;
  context?: number;
  agent?: DiffFile["agent"] | boolean;
  sourceFetcher?: FileSourceFetcher;
} = {})

Source from the content-addressed store, hash-verified

46}
47
48export function createTestDiffFile({
49 after = "const alpha = 10;\nconst beta = 2;\nconst gamma = 30;\nconst stable = true;\n",
50 before = "const alpha = 1;\nconst beta = 2;\nconst gamma = 3;\nconst stable = true;\n",
51 id = "example",
52 language = "typescript",
53 path = "example.ts",
54 previousPath,
55 context = 0,
56 agent = null,
57 sourceFetcher,
58}: {
59 after?: string;
60 before?: string;
61 id?: string;
62 language?: string;
63 path?: string;
64 previousPath?: string;
65 context?: number;
66 agent?: DiffFile["agent"] | boolean;
67 sourceFetcher?: FileSourceFetcher;
68} = {}): DiffFile {
69 const metadata = parseDiffFromFile(
70 { cacheKey: `${id}:before`, contents: before, name: path },
71 { cacheKey: `${id}:after`, contents: after, name: path },
72 { context },
73 true,
74 );
75
76 return {
77 agent: agent === true ? createTestAgentFileContext(path) : agent === false ? null : agent,
78 id,
79 language,
80 metadata,
81 patch: "",
82 path,
83 previousPath,
84 sourceFetcher,
85 stats: collectChangeStats(metadata),
86 };
87}
88
89/** Build a promise handle that lets async tests settle work manually. */
90export function createTestDeferred<T>() {

Callers 15

createExampleDiffFileFunction · 0.90
createBootstrapFunction · 0.90
createResizeBootstrapFunction · 0.90
createBootstrapFunction · 0.90
createWrapBootstrapFunction · 0.90
createDeepNoteBootstrapFunction · 0.90

Calls 2

collectChangeStatsFunction · 0.85

Tested by 15

createExampleDiffFileFunction · 0.72
createBootstrapFunction · 0.72
createResizeBootstrapFunction · 0.72
createBootstrapFunction · 0.72
createWrapBootstrapFunction · 0.72
createDeepNoteBootstrapFunction · 0.72