MCPcopy
hub / github.com/continuedev/continue / expectDiff

Function expectDiff

core/edit/lazy/deterministic.test.ts:52–84  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

50}
51
52async function expectDiff(file: string) {
53 const testFilePath = path.join(
54 __dirname,
55 "edit",
56 "lazy",
57 "test-examples",
58 file + ".diff",
59 );
60 const testFileContents = fs.readFileSync(testFilePath, "utf-8");
61 const [oldFile, newFile, expectedDiff] = testFileContents
62 .split("\n---\n")
63 .map((s) => s.replace(/^\n+/, "").trimEnd());
64 const { ourDiffs: streamDiffs } = await collectDiffs(oldFile, newFile, file);
65 const displayedDiff = displayDiff(streamDiffs);
66
67 if (!expectedDiff || expectedDiff.trim() === "") {
68 console.log(
69 "Expected diff was empty. Writing computed diff to the test file",
70 );
71 fs.writeFileSync(
72 testFilePath,
73 `${oldFile}\n\n---\n\n${newFile}\n\n---\n\n${displayDiff(
74 continueMyersDiff(oldFile, newFile),
75 )}`,
76 );
77
78 throw new Error("Expected diff is empty");
79 }
80
81 expect(normalizeDisplayedDiff(displayedDiff)).toEqual(
82 normalizeDisplayedDiff(expectedDiff),
83 );
84}
85
86describe("deterministicApplyLazyEdit(", () => {
87 test("no changes", async () => {

Callers 1

Calls 5

normalizeDisplayedDiffFunction · 0.85
collectDiffsFunction · 0.70
displayDiffFunction · 0.70
logMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected