Buckets:
| import { describe, expect, test } from "bun:test" | |
| import { patchFiles } from "./apply-patch-file" | |
| import { text } from "./session-diff" | |
| describe("apply patch file", () => { | |
| test("parses patch metadata from the server", () => { | |
| const file = patchFiles([ | |
| { | |
| filePath: "/tmp/a.ts", | |
| relativePath: "a.ts", | |
| type: "update", | |
| patch: | |
| "Index: a.ts\n===================================================================\n--- a.ts\t\n+++ a.ts\t\n@@ -1,2 +1,2 @@\n one\n-two\n+three\n", | |
| additions: 1, | |
| deletions: 1, | |
| }, | |
| ])[0] | |
| expect(file).toBeDefined() | |
| expect(file?.view.fileDiff.name).toBe("a.ts") | |
| expect(file?.view.fileDiff.isPartial).toBe(false) | |
| expect(text(file!.view, "deletions")).toBe("one\ntwo\n") | |
| expect(text(file!.view, "additions")).toBe("one\nthree\n") | |
| }) | |
| test("keeps legacy before and after payloads working", () => { | |
| const file = patchFiles([ | |
| { | |
| filePath: "/tmp/a.ts", | |
| relativePath: "a.ts", | |
| type: "update", | |
| before: "one\n", | |
| after: "two\n", | |
| additions: 1, | |
| deletions: 1, | |
| }, | |
| ])[0] | |
| expect(file).toBeDefined() | |
| expect(text(file!.view, "deletions")).toBe("one\n") | |
| expect(text(file!.view, "additions")).toBe("two\n") | |
| }) | |
| }) | |
Xet Storage Details
- Size:
- 1.31 kB
- Xet hash:
- 630ec74f979b9c43ec455be4a264e6b10e0d819ddf862db4bbb51407cde2a629
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.