mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 02:01:48 +03:00
feat(tui): refine quiet terminal interactions
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { ComposerDraft } from "./composer-draft"
|
||||
|
||||
describe("ComposerDraft", () => {
|
||||
test("keeps ordinary pastes editable as ordinary text", () => {
|
||||
const draft = new ComposerDraft()
|
||||
const insertion = draft.paste("first\r\nsecond")
|
||||
|
||||
expect(insertion).toEqual({ text: "first\nsecond", compacted: false, description: "" })
|
||||
expect(draft.expand(`before ${insertion.text} after`)).toBe("before first\nsecond after")
|
||||
})
|
||||
|
||||
test("compacts large pastes and expands only placeholders that remain", () => {
|
||||
const draft = new ComposerDraft()
|
||||
const content = Array.from({ length: 12 }, (_, index) => `line ${index}`).join("\n")
|
||||
const first = draft.paste(content)
|
||||
const second = draft.paste(content)
|
||||
|
||||
expect(first.text).toBe("[Pasted 12 lines] ")
|
||||
expect(second.text).toBe("[Pasted 12 lines #2] ")
|
||||
expect(draft.expand(`review ${first.text.trim()}`)).toBe(`review ${content}`)
|
||||
|
||||
draft.prune(second.text)
|
||||
expect(draft.expand(first.text.trim())).toBe(first.text.trim())
|
||||
expect(draft.expand(second.text.trim())).toBe(content)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user