/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/session-ui/src/components/apply-patch-file.test.ts
43 строки
1 KB
Victor Navarro
refactor(ui): isolate session components (#33670)
24 июн 2026, 17:56
Не верифицирован
24 июн 2026, 17:56
04c1730
Код
Авторство
О чём код?
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") }) })