fileSummaryTypes.test.ts 714 B

1234567891011121314151617181920212223
  1. import { describe, expect, it } from "vitest";
  2. import { normalizeSingleFilePatch } from "@/ToolCallBlocks/fileSummaryTypes.js";
  3. describe("normalizeSingleFilePatch", () => {
  4. it("adds file headers to hunk-only unified diff fragments", () => {
  5. expect(normalizeSingleFilePatch("@@ -1 +1 @@\n-old\n+new", "demo.ts")).toBe(
  6. "--- a/demo.ts\n+++ b/demo.ts\n@@ -1 +1 @@\n-old\n+new",
  7. );
  8. });
  9. it("does not wrap apply_patch payloads as fake unified diffs", () => {
  10. const patch = [
  11. "*** Begin Patch",
  12. "*** Update File: demo.ts",
  13. "@@",
  14. "-old",
  15. "+new",
  16. "*** End Patch",
  17. ].join("\n");
  18. expect(normalizeSingleFilePatch(patch, "demo.ts")).toBe(patch);
  19. });
  20. });